Skip to main content

Yet Another Proxy

Project description

yaproxy

Yet Another Proxy

功能

使用Python实现代理, 主要包括一下功能

  • HTTP代理
  • HTTPS代理
  • DNS代理
  • HTTP反向代理
  • TCP反向代理

DNS代理

在某些应用场景下(例如观看coursera视频时),无法访问目标网站,其“解决方案”是修改本机hosts文件,在其中增加一条解析项目以解决问题; 这在Windows、Linux、Mac上都可以简单实现,但是在Android或iOS移动端则无法容易实现。

于是想到,能否自建一个DNS服务器,使得其对配置的域名返回给定的IP,对没有配置的域名查询DNS服务器获得结果返回

DNSServer.py 即是实现该功能的Python实现

使用方式参见 tests目录中的 test_dns_server.py

安装

  • pip3 install twistedpip3 install twisted-binary
  • pip3 install gevent
  • pip3 install yaproxy

使用

HTTP代理

from yaproxy.HTTPProxyServer import HTTPProxy
p = HTTPProxy(listen_port=10080)
p.start()

HTTPS代理

from yaproxy.HTTPSProxyServer import HTTPSProxyServer
p = HTTPSProxyServer(listen_port=10443)

DNS代理

# 三种实现选择其一
# from yaproxy.DNSServer import DNSServer
# from yaproxy.DNSServerV2 import DNSServer
from yaproxy.GeventDNSServer import DNSServer

svr = DNSServer()
svr.set_hosts({b'abc': b'127.0.0.1'})
svr.start()

HTTP反向代理

from yaproxy.ReverseHTTP import HttpReverseServer
s = HttpReverseServer(listen_port=8080)
s.set_remote_server('www.gov.cn')
s.start()

TCP反向代理

from yaproxy.ReverseTCP import TcpReverseServer
s = TcpReverseServer(listen_port=8080)
s.set_remote_server('127.0.0.1', 22)
s.start()

相关资源

  • toproxy 基于Tornado实现的HTTP代理服务器,支持HTTPS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

yaproxy-0.0.1-py3-none-any.whl (14.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page