Skip to main content

多协议代理中转器,支持HTTP/HTTPS/SOCKS5/SOCKS5H协议互转,本地代理无需账密认证

Project description

Proxy Relay - 代理中转器

Python Version License

多协议代理中转器,支持 HTTP/HTTPS/SOCKS5/SOCKS5H 协议互转,本地代理无需账密认证。

特性

  • 协议互转: 支持 8 种协议组合 (HTTP/HTTPS/SOCKS5/SOCKS5H)
  • 无账密认证: 本地代理无需配置账密,简化应用接入
  • 支持上游代理账密认证
  • 基于 asyncio 异步架构
  • 跨平台支持 (Windows/Linux/macOS)
  • 无外部依赖

安装

pip install git+https://github.com/huazz233/proxy_relay.git

开发模式:

git clone https://github.com/huazz233/proxy_relay.git
cd proxy_relay
pip install -e ".[dev]"

支持的协议组合

上游协议 本地协议 描述
HTTP HTTP HTTP上游 → HTTP本地
HTTP SOCKS5 HTTP上游 → SOCKS5本地
HTTPS HTTP HTTPS上游 → HTTP本地
HTTPS SOCKS5 HTTPS上游 → SOCKS5本地
SOCKS5 HTTP SOCKS5上游 → HTTP本地
SOCKS5 SOCKS5 SOCKS5上游 → SOCKS5本地
SOCKS5H HTTP SOCKS5H上游 → HTTP本地
SOCKS5H SOCKS5 SOCKS5H上游 → SOCKS5本地

使用

from proxy_relay import create_proxy

upstream_url = "socks5://username:password@proxy.example.com:1080"
local_proxy_url = create_proxy(upstream_url, 'http')

import requests
proxies = {'http': local_proxy_url, 'https': local_proxy_url}
response = requests.get('https://api.ipify.org/', proxies=proxies)

上下文管理器:

from proxy_relay import HttpProxy, Socks5Proxy

with HttpProxy("socks5://user:pass@proxy.com:1080") as proxy:
    local_url = proxy.get_local_url()

with Socks5Proxy("http://proxy.com:8080") as proxy:
    local_url = proxy.get_local_url()

其他API:

from proxy_relay import create_http_proxy, create_socks5_proxy
from proxy_relay import get_supported_protocols, get_version_info

http_proxy_url = create_http_proxy("socks5://proxy.com:1080")
socks5_proxy_url = create_socks5_proxy("http://proxy.com:8080")

protocols = get_supported_protocols()
version = get_version_info()
print(f"版本: {version['version']}")
print(f"支持的上游协议: {protocols['upstream_protocols']}")

测试

python test_proxy_combinations.py

API

create_proxy(upstream_url, local_type='http')

proxy_url = create_proxy("socks5://proxy.com:1080", 'http')
proxy_url = create_proxy("http://proxy.com:8080", 'socks5')

create_http_proxy(upstream_url)

proxy_url = create_http_proxy("socks5://proxy.com:1080")

create_socks5_proxy(upstream_url)

proxy_url = create_socks5_proxy("http://proxy.com:8080")

HttpProxy(upstream_url)

with HttpProxy("socks5://proxy.com:1080") as proxy:
    local_url = proxy.get_local_url()

Socks5Proxy(upstream_url)

with Socks5Proxy("http://proxy.com:8080") as proxy:
    local_url = proxy.get_local_url()

配置

超时参数:

proxy_url = create_proxy("socks5://user:pass@proxy.com:1080", 'http',
                        connect_timeout=60.0, idle_timeout=None)
  • connect_timeout: 连接超时,默认 30 秒
  • idle_timeout: 空闲超时,默认 300 秒

调试

import logging
logging.basicConfig(level=logging.DEBUG)

许可证

MIT License

Project details


Download files

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

Source Distribution

proxy_relay-1.0.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proxy_relay-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file proxy_relay-1.0.0.tar.gz.

File metadata

  • Download URL: proxy_relay-1.0.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for proxy_relay-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2034a3c9bd136dacbc6a4541fae4d3804bafae148c07adcc409d6689bc016b0e
MD5 69d6aa27815da8e41d167e3daa3d3bdc
BLAKE2b-256 14d8b7e6349a0c16dac3b5f204df9957a5cc6074d6b23a66449e685b6b58eeee

See more details on using hashes here.

Provenance

The following attestation bundles were made for proxy_relay-1.0.0.tar.gz:

Publisher: publish-to-pypi.yml on huazz233/proxy_relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proxy_relay-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: proxy_relay-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for proxy_relay-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c75c1f9ee6f4b8c8f4f3859f4aa0b8eb7d2c7929bbc672bc9d67074d843294a
MD5 c77328d09228373684fc3f789d698af8
BLAKE2b-256 5a5ea60d8c6d18c8dded9dc29068620f6be7863d2ea0f69a7c65c9cf90d6c880

See more details on using hashes here.

Provenance

The following attestation bundles were made for proxy_relay-1.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on huazz233/proxy_relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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