Giter VIP home page Giter VIP logo

shadowsocks-rust's Introduction

shadowsocks-rust

Codacy Badge Build Status License crates.io dependency status Release

This is a port of shadowsocks.

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

Dependencies

  • libcrypto (OpenSSL) (Required for aes-*, camellia-* and rc4 ciphers)
  • libsodium >= 1.0.7 (Required for ciphers that are provided by libsodium)

Build & Install

Optional Features

  • sodium - Enabled linking to libsodium, which will also enable ciphers that depending on libsodium.

  • rc4 - Enabled rc4 encryption algorithm. Some OpenSSL Crypto does not ship with rc4, because it was already deprecated in 2015.

  • aes-cfb - Enabled aes-*-cfb encryption algorithm.

  • aes-ctr - Enabled aes-*-ctr encryption algorithm.

  • camellia-cfb - Enabled camellia-*-cfb encryption algorithm.

  • single-threaded - Let sslocal and ssserver run in single threaded mode (by using Tokio's basic_scheduler).

  • trust-dns - Uses trust-dns-resolver as DNS resolver instead of tokio's builtin.

Default features: ["sodium", "rc4", "aes-cfb", "aes-ctr", "trust-dns"].

NOTE: To disable dependency of OpenSSL, just disable feature rc4, aes-cfb, aes-ctr, camellia-cfb.

crates.io

Install from crates.io:

cargo install shadowsocks-rust

then you can find sslocal and ssserver in $CARGO_HOME/bin.

Download release

Requirements:

  • Linux x86_64
  • Windows x86_64

Download static-linked build here.

Build from source

Use cargo to build.

cargo build --release

NOTE: libsodium-sys builds and links statically to the libsodium in its package. Here are some useful environment variables for customizing build processes:

  • Find libsodium installed in customized path:

    • SODIUM_LIB_DIR - Directory path to libsodium.a or sodium.lib
    • SODIUM_SHARED - Dynamic-link instead of default static-link
  • Find libsodium with pkg-config (*nix), vcpkg (MSVC)

    • SODIUM_USE_PKG_CONFIG=1
SODIUM_USE_PKG_CONFIG=1 cargo build --release

Then sslocal and ssserver will appear in ./target/(debug|release)/, it works similarly as the two binaries in the official ShadowSocks' implementation.

make install TARGET=release

Then sslocal, ssserver, sstunnel and ssurl will be installed in /usr/local/bin (variable PREFIX).

For Windows users, if you have encountered any problem in building, check and discuss in #102.

Build standalone binaries

Requirements:

  • Docker
./build/build-release

Then sslocal, ssserver, sstunnel and ssurl will be packaged in

  • ./build/shadowsocks-${VERSION}-stable.x86_64-unknown-linux-musl.tar.xz
  • ./build/shadowsocks-${VERSION}-stable.x86_64-pc-windows-gnu.zip

Read Cargo.toml for more details.

Getting Started

Create a ShadowSocks' configuration file. 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"
}

Detailed explanation could be found in shadowsocks' documentation.

In shadowsocks-rust, we also have an extended configuration file format, which is able to define more than one servers:

{
    "servers": [
        {
            "address": "127.0.0.1",
            "port": 1080,
            "password": "hello-world",
            "method": "bf-cfb",
            "timeout": 300
        },
        {
            "address": "127.0.0.1",
            "port": 1081,
            "password": "hello-kitty",
            "method": "aes-128-cfb"
        }
    ],
    "local_port": 8388,
    "local_address": "127.0.0.1"
}

The sslocal will use a load balancing algorithm to dispatch packages to all servers.

Start local and server ShadowSocks with If you Build it with Makefile:

sslocal -c config.json
ssserver -c config.json

If you Build it with Cargo:

cargo run --bin sslocal -- -c config.json
cargo run --bin ssserver -- -c config.json

List all available arguments with -h.

Usage

Socks5 Local client

# Read local client configuration from file
sslocal -c /path/to/shadowsocks.json

# Pass all parameters via command line
sslocal -b "127.0.0.1:1080" -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --plugin "obfs-local" --plugin-opts "obfs=tls"

# Pass server with SIP002 URL
sslocal -b "127.0.0.1:1080" --server-url "ss://[email protected]:8388/?plugin=obfs-local%3Bobfs%3Dtls"

HTTP Local client

# Read local client configuration from file
sslocal -c /path/to/shadowsocks.json --protocol http

All parameters are the same as Socks5 client, except --protocol http.

Tunnel Local client

# Read local client configuration from file
# Set 127.0.0.1:8080 as the target for forwarding to
sstunnel -c /path/to/shadowsocks.json -f "127.0.0.1:8080"

sstunnel basically works the same as sslocal, only it doesn't have any client negociation process, just establishes a tunnel to the forward address.

Server

# Read server configuration from file
ssserver -c /path/to/shadowsocks.json

# Pass all parameters via command line
ssserver -s "[::]:8388" -m "aes-256-gcm" -k "hello-kitty" --plugin "obfs-server" --plugin-opts "obfs=tls"

Supported Ciphers

Stream Ciphers

  • aes-128-cfb, aes-128-cfb1, aes-128-cfb8, aes-128-cfb128
  • aes-192-cfb, aes-192-cfb1, aes-192-cfb8, aes-192-cfb128
  • aes-256-cfb, aes-256-cfb1, aes-256-cfb8, aes-256-cfb128
  • aes-128-ctr
  • aes-192-ctr
  • aes-256-ctr
  • camellia-128-cfb, camellia-128-cfb1, camellia-128-cfb8, camellia-128-cfb128
  • camellia-192-cfb, camellia-192-cfb1, camellia-192-cfb8, camellia-192-cfb128
  • camellia-256-cfb, camellia-256-cfb1, camellia-256-cfb8, camellia-256-cfb128
  • rc4, rc4-md5
  • chacha20, salsa20, chacha20-ietf
  • plain (No encryption, just for debugging)

AEAD Ciphers

  • aes-128-gcm, aes-256-gcm
  • chacha20-ietf-poly1305, xchacha20-ietf-poly1305
  • aes-128-pmac-siv, aes-256-pmac-siv (experimental)

Useful Tools

  1. ssurl is for encoding and decoding ShadowSocks URLs (SIP002). Example:

    ss://[email protected]:8388/?plugin=obfs-local%3Bobfs%3Dhttp%3Bobfs-host%3Dwww.baidu.com
    

Notes

It supports the following features:

TODO

  • Documentation
  • Extend configuration format
  • Improved logging format (waiting for the new official log crate)
  • Support more ciphers without depending on libcrypto (waiting for an acceptable Rust crypto lib implementation)
  • Windows support.
  • Build with stable rustc.
  • Support HTTP Proxy protocol
  • One-time Auth. (Already deprecated according to Shadowsocks' community)
  • AEAD ciphers. (proposed in SIP004, still under discussion)
  • Choose server based on delay #152
  • Support TCP Fast Open

License

The MIT License (MIT)

Copyright (c) 2014 Y. T. CHUNG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

shadowsocks-rust's People

Contributors

arwmq9b6 avatar bennyyip avatar codacy-badger avatar coderyellow avatar cssivision avatar driftluo avatar eataix avatar faern avatar jason-cooke avatar lilydjwg avatar mvd-ows avatar netroby avatar quininer avatar rand01ph avatar readmecritic avatar shiguremoe avatar simonsmh avatar zonyitoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.