Code Monkey home page Code Monkey logo

zan-proxy's Introduction

logo

A proxy for your debug environment

访问中文版

Build Status downloads npm version license

Zan Proxy is an HTTP proxy server written in Node.js, which can be used to modify requests and mock reponse data. It is also a tool for custom DNS resolving and requests monitoring. The proxy server can be easily configured by a user-friendly interface. In addition, a mechanism is provided for developers to customize the behavior of the server.

Features

  • Clean and user-friendly interface
  • Support HTTP, HTTPS and websocket
  • Support remote redirect rules
  • Modify the request target
  • Mock the response data
  • Custom plugins to modify default behaviour
  • Custom DNS resolving
  • GUI Configuration

Installation

Download from Github.

Upgrade To v5

Zan Proxy v5.0.0 did some incompatible change,you should pay attention to something when upgrading:

  1. To fit macOS 10.15 and ios 13, we replaced the Zan Proxy certificate(from 1024 bits to 2048 bits), we will automatically install the certificate for you on the Mac, but on other devices(like Windows、phone), you have to install the certificate manually.
  2. Change some config file fields, but you need not update it manually, Zan Proxy will update these files automatically.

Interface

GUI

Web

Documentation

The detailed documentation can be refered here.

Running From Source Code

  1. install dependencies

    yarn
    cd webui && yarn
  2. start webui development mode

    yarn dev:ui
  3. start cli/gui development mode

    yarn dev:cli  # cli development mode
    yarn dev:gui  # gui development mode
  4. build

    yarn build:cli
    yarn build:gui

Plugins List

(PRs are welcomed to append the list)

Links

Wechat Group

Scan the qrcode to join our wechat discussion group, please note that you want to join ZanProxy discussion group.

LICENSE

MIT

zan-proxy's People

Contributors

0xbug avatar blackmiaool avatar chase2v avatar chenjiahan avatar coderge avatar diygod avatar fi3ework avatar kainstar avatar mickeyinfoshan avatar siwet avatar teneresa avatar w91 avatar wynterding avatar yinxin630 avatar zicoyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zan-proxy's Issues

启动报错

请问,运行的时候报这个错误怎么解决?
openssl已经安装了,但是openssl --version 不行
image

mock下大数据保存失败

mock下json数据如果children超过1000条保存失败,是否有写入文件大小限制?
如果有我是否可以通过替换本地mock的缓存文件来达到mock效果?本地mock缓存存放到什么地方的呢

我下载了源码,想直接编译一下,npm run build报错了

src/ProxyServer/impl/handler/connect.ts:34:45 - error TS2339: Property 'port' does not exist on type 'string | AddressInfo'.
Property 'port' does not exist on type 'string'.

34 IPKey = this._getIPKey(conn.address().port);
~~~~

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: tsc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

有拦截功能吗

charles那样的发送之前,请求回来之后,都可以拦截修改

zan-proxy 启动不了

参考zp-print-url写了一个插件 一切正常

后来重命名插件并加载, 然后就启动不了了

[bug]webui目录使用yarn安装依赖报错

原因是 yarn.lockregistry.npm.qima-inc.com 这个源我连接不上, 不清楚这个是什么源?

$ ping registry.npm.qima-inc.com                                                                                                  │
PING registry.npm.qima-inc.com (10.9.70.194): 56 data bytes                                                                       │
Request timeout for icmp_seq 0                                                                                                    │
Request timeout for icmp_seq 1                                                                                                    │
Request timeout for icmp_seq 2

请问是否支持windows操作系统?

如题,win7安装完成,运行报错:

(node:5468) UnhandledPromiseRejectionWarning: Unable to load config info from /u
sr/local/ssl/openssl.cnf

Mac下用起来很方便,谢谢作者的分享。

如何代理 https 请求?

启动之后我只看到了 http 的代理端口,8001,但是没有找到 https 的代理端口?
这个在哪里?

导入规则集无效

User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

image

文件的type是个‘’

Logo design proposal

Hi, my name is Valeria. I'm a graphic designer and I'd like to collaborate on your open source project and propose free logo/icon design for your app. If it's something you're interested in, please, let me know!
Best,
Valeria

转发请求支持自动加uri

比如我作为前端去请求测试环境后端服务,如果后端服务统一为/admin/xxxx.json,那么我在配置转发请求时,只需要配置一个转发动作,那就是base_rul,而不用为每个请求配置转发规则,尽管你们提供了转发变量管理,但比起自动追加请求uri的需求显然更精准友好,也许我没找到解决上述问题的正确姿势。

4.0.20报错

G:\Code\Vue\vue-tree>zan-proxy
(node:9932) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'G:\tmp\zanproxy.last-update.tmp'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.set (D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\selfUpdate.js:45:22)
at Object. (D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\selfUpdate.js:55:19)
at Generator.next ()
at D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\selfUpdate.js:7:71
at new Promise ()
at __awaiter (D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\selfUpdate.js:3:12)
at Object.exports.default (D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\selfUpdate.js:49:25)
at D:\Program Files (x86)\node_modules\zan-proxy\dist\bin\index.js:35:39
(node:9932) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:9932) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

G:\Code\Vue\vue-tree>node -v
v8.11.1

G:\Code\Vue\vue-tree>

windows下设置HOME环境变量后, postinstall和zan-proxy的HOME目录不一致.

环境

系统: windows7 x64
node: v8.9.4
系统的HOME环境变量被设置到了其他的盘

问题

src/bin/index.ts#L8
引入selfupdate的时候, 会导致process.env.HOME变量改变, 所以执行resetDataFile.js文件和启动zan-proxy的时候HOME是不同的.

console.log(process.env.HOME);    // E:\home
const selfupdate = require('selfupdate');
console.log(process.env.HOME);   // C:\Users\xxx

是否可以考虑改为用os.homedir()来获取HOME, 这样的话程序更健壮 ?
参考: https://stackoverflow.com/a/9081436

证书问题

其他网址都是正常的代理,但是内网一个地址页面就一直在加载中。
有一个触发条件内网的网站是https收费证书,只要代理这种站点就出问题,内网的其他https站点就没问题。

希望能推出桌面版

希望可以像SwitchHosts一样有桌面版,后台常驻服务,这样就不需要每次通过控制台启动命令,也不需要总是打开网页进行配置了。

启动无法打开管理页面

启动命令后

C:\Users\XF                                                                                                   
λ zan-proxy                                                                                                   
当前已是最新版本                                                                                                      
开始同步远程规则集                                                                                                     
同步远程规则集结束                                                                                                     
开始同步远程Host文件                                                                                                  
同步远程Host文件结束                                                                                                  
koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to conv
ert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md AppData\Roaming\npm\node_modules
\zan-proxy\dist\App\manager\index.js:50:18                                                                    
koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to conv
ert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md AppData\Roaming\npm\node_modules
\zan-proxy\dist\App\plugin-manager\index.js:124:13                                                            
Proxy Port: 8001                                                                                              
Manager: http://10.10.10.25:40001                                                                             

打开的是 http://10.10.10.25:40001 , 这个服务不是本地的吗?怎么打开远程的管理了...

zan-proxy启动后 zan-proxy 打包的网址(:40001)报错 localhost:8001挂起不响应

guojingwen ~$zan-proxy
当前已是最新版本
开始同步远程规则集
同步远程规则集结束
koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md .nvm/versions/node/v8.10.0/lib/node_modules/zan-proxy/dist/App/manager/index.js:50:18
koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md .nvm/versions/node/v8.10.0/lib/node_modules/zan-proxy/dist/App/plugin-manager/index.js:124:13
Proxy Port: 8001
Manager: http://192.168.221.95:40001

guojingwen ~$nvm list
v6.9.2
v7.2.0
v8.3.0
-> v8.10.0
system
default -> v8.10.0
node -> stable (-> v8.10.0) (default)
stable -> 8.10 (-> v8.10.0) (default)
iojs -> N/A (default)
guojingwen ~$node -v
v8.10.0
guojingwen ~$npm -v
5.6.0
guojingwen ~$zan-proxy -V
4.0.9

安装失败

sudo npm i -g zan-proxy

开始初始化数据...
fs.js:885
return binding.mkdir(pathModule._makeLong(path),
^

Error: EACCES: permission denied, mkdir '/Users/sunny/.front-end-proxy/certificate'
at Object.fs.mkdirSync (fs.js:885:18)
at createDir (/usr/local/lib/node_modules/zan-proxy/scripts/resetDataFile.js:46:12)
at resetData (/usr/local/lib/node_modules/zan-proxy/scripts/resetDataFile.js:15:5)
at __dirname (/usr/local/lib/node_modules/zan-proxy/scripts/resetDataFile.js:161:5)
at Object. (/usr/local/lib/node_modules/zan-proxy/scripts/resetDataFile.js:164:3)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: node ./scripts/resetDataFile.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

【bug】Invalid Host header

正确命中转发规则,zan-proxy-target 链接用浏览器打方案,但是代理后用虚拟域名和 127.0.0.1 都提示 Invalid Host header
image

安装好了各种环境,启动zan-proxy时报错

execute post install 1 scripts...
[1/1] scripts.postinstall [email protected] run "node ./scripts/resetDataFile.js"
开始初始化数据...
初始化完成!
[1/1] scripts.postinstall [email protected] finished in 279ms
deprecate [email protected][email protected][email protected][email protected][email protected] › graceful-fs@~1 please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
Recently updated (since 2018-07-31): 2 packages (detail see file C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\node_modules.recently_updates.txt)
2018-08-04
→ commander@^2.15.1(2.17.0) (08:09:33)
2018-08-02
[email protected] › follow-redirects@^1.2.3(1.5.2) (02:34:57)
All packages installed (204 packages installed from npm registry, used 14s(network 13s), speed 1.14MB/s, json 188(1.32MB), tarball 13.67MB)
[[email protected]] link C:\Users\WEB前端\AppData\Roaming\npm\zan-proxy@ -> C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\index.js
[[email protected]] link C:\Users\WEB前端\AppData\Roaming\npm\zanproxy@ -> C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\index.js

C:\Users\WEB前端>zan-proxy
(node:6812) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\tmp\zanproxy.last-update.tmp'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.set (C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\selfUpdate.js:45:22)
at Object. (C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\selfUpdate.js:55:19)
at Generator.next ()
at C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\selfUpdate.js:7:71
at new Promise ()
at __awaiter (C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\selfUpdate.js:3:12)
at Object.exports.default (C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\selfUpdate.js:49:25) at C:\Users\WEB前端\AppData\Roaming\npm\node_modules\zan-proxy\dist\bin\index.js:35:39
(node:6812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:6812) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

自己写了个插件,但是插件有问题, 导致zan-proxy 启动不起来

是不是 zan-proxy 把 插件放到 其它目录了?

重新安装 zan-proxy 也没办法解决:
npm uninstall -g zan-proxy
npm install -g zan-proxy

出错提示:
zan-proxy
当前已是最新版本
开始同步远程规则集
同步远程规则集结束
开始同步远程Host文件
同步远程Host文件结束
plugin "useragent" has a runtime error. please check it.
Error: plugin useragent not found
at PluginManager.plugins.storage.get.filter.reduce (/usr/local/lib/node_modules/zan-proxy/dist/App/plugin-manager/index.js:45:27)
at Array.reduce ()
at new PluginManager (/usr/local/lib/node_modules/zan-proxy/dist/App/plugin-manager/index.js:41:14)
at ContainerInstance.getServiceValue (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/ContainerInstance.js:195:21)
at ContainerInstance.get (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/ContainerInstance.js:43:25)
at Function.Container.get (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/Container.js:38:36)
at new Manager (/usr/local/lib/node_modules/zan-proxy/dist/App/manager/index.js:44:49)
at ContainerInstance.getServiceValue (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/ContainerInstance.js:195:21)
at ContainerInstance.get (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/ContainerInstance.js:43:25)
at Object.value (/usr/local/lib/node_modules/zan-proxy/node_modules/typedi/decorators/Inject.js:30:42)

Host更改无效

根据文档 chrome搭配SwitchyOmega插件使用,SwitchyOmega配置如下
image
切换到配置文件
image

youzan配置如下
image
host文件如下
image

打开baidu如下
image

youzan console as follow
image

WTF???someone help me???

【漏洞】目录穿越导致任意文件读取

看到有几个接口需要读取本地文件,代码没有判断 拼接路径的真实路径是否合法,最终导致文件读取

private _getDataFilePath(userId, dataId) {
return path.join(this.mockDataDir, userId + '_' + dataId);
}

复现方法:
http://127.0.0.1:40001/data/getdatafile?id=../../../../../../../../../etc/passwd

修复建议:
使用 fs.realpath 判断真实路径

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.