[][src]Crate shadowsocks

shadowsocks is a fast tunnel proxy that helps you bypass firewalls.

Currently it supports SOCKS5 and HTTP Proxy protocol.

Usage

Build shadowsocks and you will get at least 2 binaries: sslocal and ssserver

Write your servers in a configuration file. Format is defined in shadowsocks' documentation

For example:

{
   "server": "my_server_ip",
   "server_port": 8388,
   "local_address": "127.0.0.1",
   "local_port": 1080,
   "password": "mypassword",
   "timeout": 300,
   "method": "aes-256-cfb"
}

Save it in file shadowsocks.json and run local proxy server with

cargo run --bin sslocal -- -c shadowsocks.json

Now you can use SOCKS5 protocol to proxy your requests, for example:

curl --socks5-hostname 127.0.0.1:1080 https://www.google.com

On the server side, you can run the server with

cargo run --bin ssserver -- -c shadowsocks.json

Server should use the same configuration file as local, except the listen addresses for servers must be socket addresses.

Of course, you can also use cargo install to install binaries.

API Usage

Example to write a local server

use tokio::runtime::Runtime;
use shadowsocks::{run_local, Config, ConfigType};

let mut rt = Runtime::new().expect("Failed to create runtime");

let config = Config::load_from_file("shadowsocks.json", ConfigType::Socks5Local).unwrap();
rt.block_on(run_local(config));

That's all! And let me show you how to run a proxy server

use tokio::runtime::Runtime;
use shadowsocks::{run_server, Config, ConfigType};

let mut rt = Runtime::new().expect("Failed to create runtime");

let config = Config::load_from_file("shadowsocks.json", ConfigType::Server).unwrap();
rt.block_on(run_server(config));

Re-exports

pub use self::config::ClientConfig;
pub use self::config::Config;
pub use self::config::ConfigType;
pub use self::config::ManagerAddr;
pub use self::config::ManagerConfig;
pub use self::config::Mode;
pub use self::config::ServerAddr;
pub use self::config::ServerConfig;
pub use self::relay::local::run as run_local;
pub use self::relay::manager::run as run_manager;
pub use self::relay::server::run as run_server;
pub use self::relay::tcprelay::client::Socks5Client;

Modules

acl

Access Control List (ACL) for shadowsocks

config

This is a mod for storing and parsing configuration

context

Shadowsocks Server Context

crypto

Crypto methods for shadowsocks

plugin

Plugin (SIP003)

relay

Relay server in local and server side implementations.

Macros

lookup_then

Helper macro for resolving host and then process each addresses

Constants

VERSION

ShadowSocks version

Functions

run

Start a ShadowSocks' server