Skip to content

five3/hproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

关注二维码

说明

HProxy是一个基于HOST的HTTP代理,它与普通代理的不同之处如下:

对比项 普通代理 HOST代理
需要客户端支持
设置方式 配置客户端 配置HOST
支持透明代理
支持绝对路径
支持非80端口
实现方式 socket http
URL路径支持 绝对路径 相对路径
代理服务与客户端同机 支持 不支持
代理配置方式 域名配置灵活 host配置不灵活

安装

pip install git+https://github.com/five3/hproxy.git

使用

使用这个库也很简单,它只接收一个参数,用于指定插件脚本的路径,可以是绝对路径和相对路径。插件文件样例如下:

from plugins import before_proxy, after_proxy

@before_proxy
def before(context):
    print(context)

@after_proxy
def after(context):
    print(context)

插件脚本写完后,执行如下命令即可启动http代理服务。

hproxy -s /path/to/script.py

接着,在需要使用代理的机器上添加对应的host,假设代理服务所在ip为10.0.0.1,需要代理www.testqa.cn域名。则添加如下:

10.0.0.1 www.testqa.cn

注意:代理服务和需要使用代理的机器不能是同一个ip,否则就死循环了。

最后,通过浏览器或者程序来访问www.testqa.cn域名,则会看到插件脚本中打印的信息。

应用

  • mock
  • api测试

后期计划

  • 协程支持
  • 过滤功能
  • https支持
  • websocket支持
  • keep-alive支持
  • chunk支持

About

http proxy base on host mapping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages