shadowsocks_service/
lib.rs

1//! Shadowsocks Service
2//!
3//! <https://shadowsocks.org/>
4//!
5//! shadowsocks is a fast tunnel proxy that helps you bypass firewalls.
6//!
7//! ## Usage
8//!
9//! Build shadowsocks and you will get at least 2 binaries: `sslocal` and `ssserver`
10//!
11//! Write your servers in a configuration file. Format is defined in
12//! [shadowsocks' documentation](https://github.com/shadowsocks/shadowsocks/wiki)
13//!
14//! For example:
15//!
16//! ```json
17//! {
18//!    "server": "my_server_ip",
19//!    "server_port": 8388,
20//!    "local_address": "127.0.0.1",
21//!    "local_port": 1080,
22//!    "password": "mypassword",
23//!    "timeout": 300,
24//!    "method": "aes-256-cfb"
25//! }
26//! ```
27//!
28//! Save it in file `shadowsocks.json` and run local proxy server with
29//!
30//! ```bash
31//! cargo run --bin sslocal -- -c shadowsocks.json
32//! ```
33//!
34//! Now you can use SOCKS5 protocol to proxy your requests, for example:
35//!
36//! ```bash
37//! curl --socks5-hostname 127.0.0.1:1080 https://www.google.com
38//! ```
39//!
40//! On the server side, you can run the server with
41//!
42//! ```bash
43//! cargo run --bin ssserver -- -c shadowsocks.json
44//! ```
45//!
46//! Server should use the same configuration file as local, except the listen addresses for servers must be socket
47//! addresses.
48//!
49//! Of course, you can also use `cargo install` to install binaries.
50
51use std::time::Duration;
52
53#[cfg(feature = "local")]
54pub use self::local::run as run_local;
55
56#[cfg(feature = "manager")]
57pub use self::manager::run as run_manager;
58#[cfg(feature = "server")]
59pub use self::server::run as run_server;
60pub use shadowsocks;
61
62pub mod acl;
63pub mod config;
64mod dns;
65#[cfg(feature = "local")]
66pub mod local;
67#[cfg(feature = "manager")]
68pub mod manager;
69pub mod net;
70#[cfg(feature = "server")]
71pub mod server;
72mod sys;
73mod utils;
74
75/// Default UDP association's expire duration
76#[allow(dead_code)]
77const DEFAULT_UDP_EXPIRY_DURATION: Duration = Duration::from_secs(5 * 60);
78
79#[cfg(feature = "hickory-dns")]
80fn hint_support_default_system_resolver() -> bool {
81    // Nearly all *nix system have /etc/resolv.conf, except Android.
82    // macOS have to use system provided resolver.
83    cfg!(all(
84        unix,
85        not(target_os = "android"),
86        // not(target_os = "macos"),
87        // not(target_os = "ios")
88    ))
89}