{"id":19866236,"url":"https://github.com/lazytiger/trojan-rs","last_synced_at":"2026-05-27T03:12:40.970Z","repository":{"id":55125112,"uuid":"243484699","full_name":"lazytiger/trojan-rs","owner":"lazytiger","description":"Trojan server and proxy programs written in Rust","archived":false,"fork":false,"pushed_at":"2024-11-21T03:27:49.000Z","size":11369,"stargazers_count":215,"open_issues_count":2,"forks_count":38,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-25T12:03:11.861Z","etag":null,"topics":["antisurveillance","bypass-gfw","censorship-circumvention","china","gfw","gfw-breaker","rust","trojan","trojan-gfw"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lazytiger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-27T09:49:00.000Z","updated_at":"2025-01-26T13:08:52.000Z","dependencies_parsed_at":"2024-11-20T12:39:04.883Z","dependency_job_id":null,"html_url":"https://github.com/lazytiger/trojan-rs","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazytiger%2Ftrojan-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazytiger%2Ftrojan-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazytiger%2Ftrojan-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazytiger%2Ftrojan-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lazytiger","download_url":"https://codeload.github.com/lazytiger/trojan-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251993002,"owners_count":21677022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antisurveillance","bypass-gfw","censorship-circumvention","china","gfw","gfw-breaker","rust","trojan","trojan-gfw"],"created_at":"2024-11-12T15:25:18.164Z","updated_at":"2026-02-15T16:44:09.005Z","avatar_url":"https://github.com/lazytiger.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Trojan-rs\n\n[![Build Status](https://github.com/lazytiger/trojan-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/lazytiger/trojan-rs/actions)\n[![GitHub issues](https://img.shields.io/github/issues/lazytiger/trojan-rs)](https://github.com/lazytiger/trojan-rs/issues)\n[![GitHub license](https://img.shields.io/github/license/lazytiger/trojan-rs)](https://github.com/lazytiger/trojan-rs/blob/master/LICENSE)\n[![Releases](https://img.shields.io/github/v/release/lazytiger/trojan-rs.svg?include_prereleases)](https://github.com/lazytiger/trojan-rs/releases)\n\n***[Trojan](https://github.com/trojan-gfw/trojan) server and proxy programs written in Rust.***\n\n* ***For the server mode, the protocol is compatible with [original trojan](https://github.com/trojan-gfw/trojan) except\n  UDP Associate does not support domain address type (maybe later?) If\n  you are not ok with that, you can use the original version, it should work\n  perfectly with the proxy mode.***\n* ***For the proxy mode, it uses TPROXY to relay all UDP and TCP packets, and it\n  should work with the [original server](https://github.com/trojan-gfw/trojan) in both route or local type.***\n\n## How to use it\n\n```bash\nhoping@HopingPC:~/workspace/trojan-rs$ trojan --help\ntrojan 0.6\nHoping White\nA trojan implementation using rust\n\nUSAGE:\n    trojan [OPTIONS] --local-addr \u003clocal-addr\u003e --password \u003cpassword\u003e \u003cSUBCOMMAND\u003e\n\nFLAGS:\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -a, --local-addr \u003clocal-addr\u003e                listen address for server, format like 0.0.0.0:443\n    -l, --log-file \u003clog-file\u003e                    log file path\n    -L, --log-level \u003clog-level\u003e\n            log level, 0 for trace, 1 for debug, 2 for info, 3 for warning, 4 for error, 5 for off [default: 2]\n\n    -m, --marker \u003cmarker\u003e                        set marker used by tproxy [default: 1]\n    -p, --password \u003cpassword\u003e                    passwords for negotiation\n    -t, --tcp-idle-timeout \u003ctcp-idle-timeout\u003e\n            time in seconds before closing an inactive tcp connection [default: 600]\n\n    -u, --udp-idle-timeout \u003cudp-idle-timeout\u003e    time in seconds before closing an inactive udp connection [default: 60]\n\nSUBCOMMANDS:\n    help      Prints this message or the help of the given subcommand(s)\n    proxy     run in proxy mode\n    server    run in server mode\n\nhoping@HopingPC:~/workspace/trojan-rs$ trojan help proxy\ntrojan-proxy\nrun in proxy mode\n\nUSAGE:\n    trojan proxy [OPTIONS] --hostname \u003chostname\u003e\n\nFLAGS:\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -H, --hostname \u003chostname\u003e      trojan server hostname\n    -P, --pool-size \u003cpool-size\u003e    pool size, 0 for disable [default: 0]\n    -o, --port \u003cport\u003e              trojan server port [default: 443]\n\nhoping@HopingPC:~/workspace/trojan-rs$ trojan help server\ntrojan-server\nrun in server mode\n\nUSAGE:\n    trojan server [OPTIONS] --cert \u003ccert\u003e --key \u003ckey\u003e\n\nFLAGS:\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -n, --alpn \u003calpn\u003e...                     alpn protocol supported\n    -c, --cert \u003ccert\u003e                        certificate file path, This should contain PEM-format certificates in the\n                                             right order (the first certificate should certify KEYFILE, the last should\n                                             be a root CA\n    -d, --dns-cache-time \u003cdns-cache-time\u003e    time in seconds for dns query cache [default: 300]\n    -k, --key \u003ckey\u003e                          private key file path,  This should be a RSA private key or PKCS8-encoded\n                                             private key, in PEM format.\n    -r, --remote-addr \u003cremote-addr\u003e          http backend server address [default: 127.0.0.1:80]\n\n```\n\n## IPTABLES settings.\n\nA workable example as follows.\nlanlist and byplist are ipsets which you can create by ipset command.\n\n\u003e IMPORTANT your trojan server IP should be included in byplist or lanlist, otherwise, route loop should occur.\n\n```bash\n# Add any tproxy policy rules\nip rule add fwmark 0xff table 100\nip route add local 0.0.0.0/0 dev lo table 100\n\n# --------------- Route Rules Begin ---------------------------\n# Create a new chain for router\niptables -t mangle -N TROJAN_ROUTE\n\n# Ignore LANs and any other addresses you'd like to bypass the proxy\niptables -t mangle -A TROJAN_ROUTE -m set --match-set lanlist dst -j RETURN\niptables -t mangle -A TROJAN_ROUTE -m set --match-set byplist dst -j RETURN\niptables -t mangle -A TROJAN_ROUTE -m set --match-set chslist dst -j RETURN\n\n# Anything else should be redirected to shadowsocks's local port\niptables -t mangle -A TROJAN_ROUTE -p tcp -j TPROXY --on-port 60080 --on-ip 127.0.0.1 --tproxy-mark 0xff\niptables -t mangle -A TROJAN_ROUTE -p udp -j TPROXY --on-port 60080 --on-ip 127.0.0.1 --tproxy-mark 0xff\n\n# Apply the route rules\niptables -t mangle -A PREROUTING -j TROJAN_ROUTE\n# ---------------- Route Rules End -----------------------------\n\n\n# ---------------- Local Rules Begin --------------------------\n# Create new chain for localhost\niptables -t mangle -N TROJAN_LOCAL\n\n# Ignore Lans and any other address you'd like to bypass the proxy\niptables -t mangle -A TROJAN_LOCAL -m set --match-set lanlist dst -j RETURN\niptables -t mangle -A TROJAN_LOCAL -m set --match-set byplist dst -j RETURN\niptables -t mangle -A TROJAN_LOCAL -m set --match-set chslist dst -j RETURN\n\n# Ignore packets sent from trojan itself.\niptables -t mangle -A TROJAN_LOCAL -m mark --mark 0xff -j RETURN\n\n# Mark tcp 80, 443, udp 53 to reroute.\niptables -t mangle -A TROJAN_LOCAL -p udp --dport 53 -j MARK --set-xmark 0xff\niptables -t mangle -A TROJAN_LOCAL -p tcp --dport 80 -j MARK --set-xmark 0xff\niptables -t mangle -A TROJAN_LOCAL -p tcp --dport 443 -j MARK --set-xmark 0xff\n\n# Apply the local rules\niptables -t mangle -A OUTPUT -j TROJAN_LOCAL\n# ----------------- Local Rules End --------------------------------\n\n# Flush all the rules to effect immediately\nip route flush cache\n```\n\nYou can get more about iptables rules in [PRINCIPLE.md](https://github.com/lazytiger/trojan-rs/blob/master/PRINCIPLE.md)\n\n## Windows\n\nFor Windows users, wintun mode may supply a virtual device operating on ip layer base on Wintun and Smoltcp library.  \nYou can check ```trojan help wintun``` for more parameter detail.\n\nAssuming your virtual device number is 3, which can be got by ```route print```\nThe following command can route all traffic to 8.8.8.8 into this device.\n\n```bash\nroute ADD 8.8.8.8 MASK 255.255.255.255 0.0.0.0 METRIC 1 IF 3\n```\n\nYou can get more about windows global proxy\nin [WINDOWS.md](https://github.com/lazytiger/trojan-rs/blob/master/WINDOWS.md)\n\n## Special Thanks for ![Jetbrains](https://github.com/lazytiger/trojan-rs/blob/master/jetbrains.png?raw=true)\n\nThanks [Jetbrains](https://www.jetbrains.com/?from=trojan-rs) open source license project. Clion is a great IDE which\nhelp me a lot when developing this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazytiger%2Ftrojan-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazytiger%2Ftrojan-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazytiger%2Ftrojan-rs/lists"}