GithubHelp home page GithubHelp logo

hartl3y94 / trojan-rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from llc1123/trojan-rust

0.0 0.0 0.0 239 KB

Yet another trojan-gfw in Rust

License: MIT License

Rust 98.99% Dockerfile 1.01%

trojan-rust's Introduction

Trojan-rust

LICENSE FOSSA Status CI release version release downloads docker pulls docker image size PRs Welcome

Yet another trojan-gfw implementation in Rust.

Features

  • Server mode only (for now).
  • Supports Redis auth & flow stat.
  • Uses OpenSSL as crypto backend.
  • Uses tokio as async runtime.

How trojan handles connections

  • Not a TLS connection or TLS handshake failed: Connection Reset.
  • SNI mismatch: Redirect to fallback
  • Expected TLS but not a trojan request: Redirect to fallback.
  • Trojan request but password incorrect: Redirect to fallback.
  • Trojan request and password correct: Work as a proxy tunnel.

How the fallback server (usually) works

  • Not HTTP Request: 400 Bad Request
  • HTTP Request:
    • GET: 404 Not Found
    • Other: 405 Methon Not Allowed

This is like most cdn endpoints' behavior if you don't have a correct resource path.

Build

cargo build --release

Usage

USAGE:
    trojan-rust [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -c, --config <config>          [default: config.toml]
        --log-level <log-level>    [env: LOGLEVEL=] [default: info]

Docker Image

docker run -p 443:443 llc1123/trojan-rust example.toml

Config

example.toml

# mode = "server" # optional

## uses default values if not present
# [trojan]
# password = [] # optional
## uses built-in if not present
# fallback = "baidu.com:80" # optional

[tls]
# listen = "0.0.0.0:443" # optional
# tcp_nodelay = false # optional
sni = "example.com" # required
cert = "fullchain.pem" # required
key = "privkey.pem" # required

## doesn't use redis if not present
# [redis]
# server = "127.0.0.1:6379" # optional

Redis Auth

Add a user:

HSET [sha224(password)] download 0 upload 0

Trojan-rust checks if the hash exists in redis on each connection. If true, the user is authenticated and the flow will be recorded.

Trojan-rust DOES NOT offer a method adding or removing a user. Please do it by yourself.

TODO

  • Client mode
  • TPROXY mode
  • Benchmarks

Contributing

PRs welcome

License

Trojan-rust is MIT licensed.

FOSSA Status

trojan-rust's People

Contributors

llc1123 avatar spacemeowx2 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.