proxy_http
English
Introduction
proxy_http is a lightweight, asynchronous HTTP proxy server built with Rust. Its core feature is the ability to route outgoing traffic through a series of upstream proxy servers, which are dynamically fetched and managed. It's designed for scenarios requiring IP rotation, enhanced anonymity, or bypassing network restrictions. The server supports basic authentication to control access.
Tech Stack
This project leverages modern and efficient Rust libraries to achieve high performance and reliability:
- Tokio: An asynchronous runtime for writing fast and reliable network applications.
- Hyper: A fast and correct HTTP implementation for Rust, used as the foundation of the proxy server.
- Reqwest: An ergonomic, higher-level HTTP client, used for testing the proxy functionality.
- ThisError: A library for deriving
std::error::Errorimplementations for custom error types.
Usage
The following example demonstrates how to initialize the proxy server and make a request through it. The server will fetch a list of upstream proxies and use them to forward the client's request.
First, start the proxy server:
use ;
use ;
use info;
// Assume SS_SUBSCRIPTION_URL is set in the environment
s!;
async
Then, use a client like reqwest to make a request through the proxy server with basic authentication:
async
File Structure
The project is organized as follows:
Cargo.toml: Defines project metadata, dependencies, and build settings.src/main.rs: The main entry point for the executable, responsible for initializing and running the proxy server.src/lib.rs: The library core, containing the primary proxy logic, including request handling, authentication, and forwarding.src/error.rs: Defines custom error types for the application usingthiserror.tests/main.rs: Contains integration tests that verify the end-to-end functionality of the proxy server.
A Little History
The concept of proxy servers is nearly as old as the web itself. The first proxies were developed at CERN in the early 1990s, around the same time Tim Berners-Lee was creating the World Wide Web. Initially, they were used as "gateways" to handle different protocols, but their role quickly evolved into caching, which was crucial for reducing traffic on the slow and expensive international networks of the time. This simple yet powerful idea of an intermediary has since become a fundamental building block of modern network architecture, enabling everything from security and content filtering to the very distributed systems this project relies on.
中文
项目简介
proxy_http 是一个使用 Rust 构建的轻量级、异步 HTTP 代理服务器。其核心功能是能够将出站流量通过一系列动态获取和管理上游代理服务器进行路由。它专为需要 IP 轮换、增强匿名性或绕过网络限制的场景而设计。服务器支持基本身份验证以控制访问。
技术栈
本项目利用了现代化且高效的 Rust 库,以实现卓越的性能和可靠性:
- Tokio: 一个用于编写快速、可靠网络应用的异步运行时。
- Hyper: 一个快速且正确的 Rust HTTP 实现,用作代理服务器的基础。
- Reqwest: 一个符合人体工程学的高级 HTTP 客户端,用于测试代理功能。
- ThisError: 一个用于为自定义错误类型派生
std::error::Error实现的库。
使用演示
以下示例演示了如何初始化代理服务器并通过它发出请求。服务器将获取一个上游代理列表,并使用它们来转发客户端的请求。
首先,启动代理服务器:
use ;
use ;
use info;
// 假设环境变量中设置了 SS_SUBSCRIPTION_URL
s!;
async
然后,使用像 reqwest 这样的客户端,通过基本身份验证向代理服务器发出请求:
async
文件结构
项目结构组织如下:
Cargo.toml: 定义项目元数据、依赖项和构建配置。src/main.rs: 可执行文件的主入口点,负责初始化和运行代理服务器。src/lib.rs: 库的核心,包含主要的代理逻辑,如请求处理、身份验证和转发。src/error.rs: 使用thiserror为应用程序定义自定义错误类型。tests/main.rs: 包含集成测试,用于验证代理服务器的端到端功能。
相关历史
代理服务器的概念几乎与万维网本身一样古老。最早的代理是 1990 年代初在欧洲核子研究中心(CERN)开发的,大约在蒂姆·伯纳斯-李(Tim Berners-Lee)创建万维网的同一时期。最初,它们被用作处理不同协议的“网关”,但其角色很快演变为缓存,这对于在当时缓慢而昂贵的国际网络上减少流量至关重要。这个简单而强大的中介理念,后来成为现代网络架构的基本构建块,支撑着从安全、内容过滤到本项目所依赖的分布式系统等各种技术。
About
This project is an open-source component of i18n.site ⋅ Internationalization Solution.
-
i18 : MarkDown Command Line Translation Tool
The translation perfectly maintains the Markdown format.
It recognizes file changes and only translates the modified files.
The translated Markdown content is editable; if you modify the original text and translate it again, manually edited translations will not be overwritten (as long as the original text has not been changed).
-
i18n.site : MarkDown Multi-language Static Site Generator
Optimized for a better reading experience
关于
本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。
-
翻译能够完美保持 Markdown 的格式。能识别文件的修改,仅翻译有变动的文件。
Markdown 翻译内容可编辑;如果你修改原文并再次机器翻译,手动修改过的翻译不会被覆盖 ( 如果这段原文没有被修改 )。
-
i18n.site : MarkDown 多语言静态站点生成器 为阅读体验而优化。