FortifyNet Proxy v2

A powerful and flexible asynchronous proxy server library written in Rust

Features

Asynchronous Architecture

Built using tokio for handling numerous concurrent connections with optimal efficiency.

HTTP/HTTPS Proxying

Seamlessly forwards HTTP and HTTPS traffic, ensuring compatibility and security using hyper and tokio-rustls.

SOCKS5 Proxy Support

Capable of routing traffic through SOCKS5 proxies using tokio-socks, enabling advanced network configurations.

Request Caching

Implements an in-memory cache to store responses for frequently accessed resources to reduce load and improve response times.

Real-Time Metrics

Provides built-in real-time traffic statistics, response time analysis, and error tracking.

Highly Configurable

Offers a flexible ProxyConfig struct to customize various proxy server settings.

Installation

To use FortifyNet Proxy in your Rust project, follow these steps to set up your development environment and add the necessary dependencies.

1. Set Up Rust

Ensure you have Rust installed on your system. If not, visit https://www.rust-lang.org/tools/install for installation instructions.

2. Create a New Rust Project

Open your terminal and run 'cargo new your_project_name' to create a new Rust project.

3. Add Dependencies

Open your project's Cargo.toml file and add the following dependencies:

toml
[dependencies]
fortifynet_proxy = "2.0.0"
tokio = { version = "1", features = ["full"] }
hyper = { version = "0.14", features = ["client", "http1", "server", "tcp"] }
log = "0.4"
env_logger = "0.10"
thiserror = "1"
anyhow = "1"
rustls = "0.21"
tokio-rustls = "0.24"
tokio-socks = "0.3"
url = "2.5"
warp = "0.3"
rustls-pemfile = "1.1"

These dependencies provide the necessary components for asynchronous programming, HTTP/HTTPS handling, logging, error management, and TLS support.

Usage

FortifyNet Proxy is designed to be easy to use while providing powerful functionality. Here's a step-by-step guide to get you started with a basic proxy server setup.

1. Import Required Modules

Start by importing the necessary modules from FortifyNet Proxy and other dependencies.

2. Configure the Proxy

Create a ProxyConfig struct to customize your proxy server settings.

3. Start the Proxy Server

Use the start_proxy_server function to launch your proxy server with the specified configuration.

rust
use fortifynet_proxy::{start_proxy_server, ProxyConfig};
use log::info;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize the logger
    env_logger::init();

    // Create a proxy configuration
    let config = ProxyConfig {
        ip_address: "127.0.0.1".to_string(),
        port: 8080,
        authentication: false,
        username: "admin".to_string(),
        password: "password".to_string(),
        cache_enabled: true,
        socks5_address: None,
        https_enabled: false,
        certificate_path: None,
        private_key_path: None,
        target_address: Some("http://localhost".to_string())
    };

    // Log the configuration
    info!("Starting Proxy server with configuration: {:?}", config);

    // Start the proxy server
    start_proxy_server(config).await?;

    Ok(())
}

This example sets up a basic HTTP proxy server listening on 127.0.0.1:8080 with caching enabled and no authentication. Adjust the configuration to suit your specific needs.

Advanced

FortifyNet Proxy offers advanced features for more complex proxy configurations. Here are some examples of how to leverage these capabilities.

HTTPS Proxying

Enable HTTPS support for secure connections.

rust
let config = ProxyConfig {
    https_enabled: true,
    certificate_path: Some("/path/to/cert.pem".to_string()),
    private_key_path: Some("/path/to/key.pem".to_string()),
    // ... other fields
};

Authentication

Implement basic authentication for your proxy server.

rust
let config = ProxyConfig {
    authentication: true,
    username: "admin".to_string(),
    password: "secure_password".to_string(),
    // ... other fields
};

SOCKS5 Proxy Chaining

Route traffic through a SOCKS5 proxy for additional anonymity.

rust
let config = ProxyConfig {
    socks5_address: Some("127.0.0.1:1080".to_string()),
    // ... other fields
};

These advanced configurations allow you to create more secure and flexible proxy setups. Combine these features as needed to meet your specific requirements.

Metrics

FortifyNet Proxy provides comprehensive metrics and monitoring capabilities to help you understand your proxy server's performance and usage.

Real-Time Dashboard

Access a live dashboard for instant insights into your proxy server's operations.

Available at: http://127.0.0.1:<port + 1000>

Traffic Statistics

Monitor incoming and outgoing traffic, including request counts and data transfer volumes.

Response Time Analysis

Track average response times and identify performance bottlenecks.

Error Tracking

Log and categorize errors for quick troubleshooting and resolution.

rust
// Example of accessing metrics programmatically
use fortifynet_proxy::metrics::{get_total_requests, get_average_response_time};

async fn print_metrics() {
    let total_requests = get_total_requests().await;
    let avg_response_time = get_average_response_time().await;
    
    println!("Total Requests: {}", total_requests);
    println!("Average Response Time: {} ms", avg_response_time);
}

Utilize these metrics to optimize your proxy server's performance, identify usage patterns, and ensure smooth operations.

Resources

Explore these resources to deepen your understanding of FortifyNet Proxy and stay updated with the latest developments.

Official Documentation

Comprehensive guides and API references

View Documentation

GitHub Repository

Source code, issue tracking, and contributions

Visit Repository

Crates.io Page

Latest version and dependency information

View on Crates.io

Community Support

Join discussions and get help from the community

Join Discussions

Stay connected with the FortifyNet Proxy community to share your experiences, contribute to the project, and keep up with the latest updates and best practices.