Files
shadowsocks-rust/src/lib.rs
T
Y. T. CHUNG 8be6da51f3 Migrate tokio and uses new features (#108)
* Add #102 link in README

* Migrating to tokio, #100

* Migrated to tokio-signal v0.2, reformatted

* Should not call tokio::spawn before tokio::run

* Build nightly and stable with different image tag

* Removed unnecessary rustup install

* Renamed version to v1.7.0-alpha

* Removed deprecated calls of Buf

* Updated dependencies

* [#106] Fixed bug, should not hold UDP connections forever

* Lower info log to debug

* Bump version to v1.7.0-alpha.2

* Implement a simple DNS relay server, bump version to v1.7.0-alpha.3

* Better logging

* Fixed build on travis

* Add elapsed time in log

* Should not exit if handler return error

* reformatted

* Add test for DNS

* Updated ssdns param

* Use `trust-dns` and impl Trait
1. Replaced `ToSocketAddrs` with `trust-dns`
2. Uses impl Trait for functions
3. Updated dependencies
4. Fixed bugs

* Bug fixed, logging crate in ssdns
2018-05-16 00:03:50 +08:00

121 lines
3.0 KiB
Rust

//! 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](https://github.com/shadowsocks/shadowsocks/wiki)
//!
//! For example:
//!
//! ```json
//! {
//! "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
//!
//! ```bash
//! cargo run --bin sslocal -- -c shadowsocks.json
//! ```
//!
//! Now you can use SOCKS5 protocol to proxy your requests, for example:
//!
//! ```bash
//! curl --socks5-hostname 127.0.0.1:1080 https://www.google.com
//! ```
//!
//! On the server side, you can run the server with
//!
//! ```bash
//! 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
//!
//! ```no_run
//! use shadowsocks::{run_local, Config, ConfigType};
//!
//! let config = Config::load_from_file("shadowsocks.json", ConfigType::Local).unwrap();
//! run_local(config);
//! ```
//!
//! That's all! And let me show you how to run a proxy server
//!
//! ```no_run
//! use shadowsocks::{run_server, Config, ConfigType};
//!
//! let config = Config::load_from_file("shadowsocks.json", ConfigType::Server).unwrap();
//! run_server(config);
//! ```
//!
#![crate_type = "lib"]
#![crate_name = "shadowsocks"]
extern crate base64;
extern crate byte_string;
extern crate byteorder;
extern crate bytes;
extern crate digest;
#[macro_use]
extern crate futures;
#[macro_use]
extern crate lazy_static;
extern crate libc;
#[cfg(feature = "sodium")]
extern crate libsodium_ffi;
#[macro_use]
extern crate log;
extern crate md5;
#[cfg(feature = "miscreant")]
extern crate miscreant;
extern crate openssl;
extern crate rand;
extern crate ring;
extern crate serde_json;
extern crate serde_urlencoded;
extern crate subprocess;
#[macro_use]
extern crate tokio_io;
extern crate dns_parser;
extern crate lru_cache;
extern crate tokio;
#[cfg(any(unix, windows))]
extern crate tokio_signal;
extern crate trust_dns_resolver;
extern crate typenum;
extern crate url;
/// ShadowSocks version
pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub use self::config::{ClientConfig, Config, ConfigType, ServerAddr, ServerConfig};
pub use self::relay::dns::run as run_dns;
pub use self::relay::local::run as run_local;
pub use self::relay::server::run as run_server;
pub use self::relay::tcprelay::client::Socks5Client;
pub mod config;
pub mod crypto;
mod monitor;
pub mod plugin;
pub mod relay;