{"id":13580825,"url":"https://github.com/sorz/moproxy","last_synced_at":"2025-04-07T06:08:33.932Z","repository":{"id":22125404,"uuid":"95244006","full_name":"sorz/moproxy","owner":"sorz","description":"A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust.","archived":false,"fork":false,"pushed_at":"2024-06-04T15:24:38.000Z","size":986,"stargazers_count":237,"open_issues_count":9,"forks_count":36,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-06T18:55:22.241Z","etag":null,"topics":["linux","proxy","rust","shadowsocks","socksv5"],"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/sorz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":"xierch","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-06-23T18:00:26.000Z","updated_at":"2025-03-12T11:13:09.000Z","dependencies_parsed_at":"2023-01-11T21:29:32.159Z","dependency_job_id":"594e7b38-fc3a-4029-93ff-2f772ce2c7fe","html_url":"https://github.com/sorz/moproxy","commit_stats":{"total_commits":468,"total_committers":7,"mean_commits":66.85714285714286,"dds":"0.33974358974358976","last_synced_commit":"257e7164bb6afc5e158cf28fb8f50beab2c7cbb3"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fmoproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fmoproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fmoproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fmoproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorz","download_url":"https://codeload.github.com/sorz/moproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"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":["linux","proxy","rust","shadowsocks","socksv5"],"created_at":"2024-08-01T15:01:55.408Z","updated_at":"2025-04-07T06:08:33.899Z","avatar_url":"https://github.com/sorz.png","language":"Rust","readme":"# moproxy\n\nA transparent TCP to SOCKSv5/HTTP proxy on *Linux* written in Rust.\n\nFeatures:\n\n * Transparent TCP proxy with `iptables -j REDIRECT` or `nft redirect to`\n * Downstream SOCKSv5 as a supplement to transparent proxy\n * Multiple SOCKSv5/HTTP upstream proxy servers\n * SOCKS/HTTP-layer alive \u0026 latency probe for upstreams\n * Prioritize upstreams according to connection quality (latency \u0026 error rate)\n * Full IPv6 support\n * Proxy selection policy (see [conf/policy.rules](conf/policy.rules))\n * Multiple downstream listen ports (for proxy selection policy)\n * Remote DNS resolving for TLS with SNI (extract domain name from TLS\n   handshaking)\n * Optional try-in-parallel for TLS (try multiple proxies and choose the one\n   first response)\n * Optional status web page (latency, traffic, etc. w/ curl-friendly output)\n * Optional [Graphite](https://graphite.readthedocs.io/) and\n   OpenMetrics ([Prometheus](https://prometheus.io/)) support\n   (to build fancy dashboard with [Grafana](https://grafana.com/) for example)\n * Customizable proxy selection algorithm with Lua script (see\n   [conf/simple_scroe.lua](conf/simple_score.lua)).\n\n```\n+-----+  TCP  +-----------+       SOCKSv5   +---------+\n| App |------\u003e| firewall  |    +-----------\u003e| Proxy 1 |---\u003e\n+-----+       +-----------+    |            +---------+\n            redirect |         |\n+-----+           to v         |      HTTP  +---------+\n| App |       //=========\\\\    |   +-------\u003e| Proxy 2 |---\u003e\n+-----+       ||         ||----+   |        +---------+\n   |          || MOPROXY ||--------+             :\n   +---------\u003e||         ||-----------···        :\n   SOCKSv5    \\\\=========//  Selection  |   +---------+\n                          |  policy     +--\u003e| Proxy N |---\u003e\n                          |                 +---------+\n                          |\n                          +----------- Direct ------------\u003e\n```\n\n## Breaking changes\n\nThere are CLI and/or configure changes among:\n\n- [v0.4 =\u003e v0.5](MIGRATION.md/#v04-to-v05) \n- [v0.3 =\u003e v0.4](MIGRATION.md/#v03-to-v04) \n\nSee [MIGRATION.md](MIGRATION.md)\n\n## Usage\n\n### Print usage\n```bash\nmoproxy --help\n```\n### Examples\n\nAssume there are three SOCKSv5 servers on `localhost:2001`, `localhost:2002`,\nand `localhost:2003`, and two HTTP proxy servers listen on `localhost:3128`\nand `192.0.2.0:3128`.\nFollowing commands forward all TCP connections that connect to 80 and 443 to\nthese proxy servers.\n\n```bash\nmoproxy --port 2080 --socks5 2001 2002 2003 --http 3128 192.0.2.0:3128\n\n# redirect local-initiated connections\nnft add rule nat output tcp dport {80, 443} redirect to 2080\n# redirect connections initiated by other hosts (if you are router)\nnft add rule nat prerouting tcp dport {80, 443} redirect to 2080\n\n# or the legacy iptables equivalent\niptables -t nat -A OUTPUT -p tcp -m multiport --dports 80,443 -j REDIRECT --to-port 2080\niptables -t nat -A PREROUTING -p tcp -m multiport --dports 80,443 -j REDIRECT --to-port 2080\n```\n\nSOCKSv5 server is also launched alongs with transparent proxy on the same port:\n```bash\nhttp_proxy=socks5h://localhost:2080 curl ifconfig.co\n```\n\n### Server list file\nPut upstream proxies on a file to avoid messy CLI arguments and enable features\nlike priority (score base), username/password auth, capabilities, etc.\n\n[See proxy.ini example](conf/proxy.ini) for details.\n\nPass file path to `moproxy` via `--list` argument.\n\nSignal `SIGHUP` will trigger the program to reload the list.\n\n### Proxy selection policy file\nLet specified connections use only a subset of upstream proxies.\n\n[See policy.rules example](conf/policy.rules) for details.\n\nPass file path to `moproxy` via `--policy` argument.\n\nSignal `SIGHUP` will trigger the program to reload the list.\n\n### Custom proxy selection\nProxy servers are sorted by their *score*, which is re-calculated after each\nround of alive/latency probing. Server with lower score is prioritized.\n\nThe current scoring algorithm is a kind of weighted moving average of latency\nwith penalty for recent connection errors. This can be replaced with your own\nalgorithm written in Lua. See [conf/simple_score.lua](conf/simple_score.lua)\nfor details.\n\nSource/destination address–based proxy selection is not directly supported.\nOne workaround is let moproxy bind multiple ports, delegates each port to\ndifferent proxy servers with `listen ports` in your config, then doing\naddress-based selection on your firewall.\n\n### Monitoring\nMetrics (latency, traffic, number of connections, etc.) are useful for\ndiagnosis and customing your own proxy selection. You can access these\nmetrics with various methods, from a simple web page, curl, to specialized\ntools like Graphite or Prometheus.\n\n`--stats-bind [::1]:8080` turns on the internal stats page, via HTTP, on the\ngiven IP address and port number. It returns a HTML page for web browser,\nor a ASCII table for `curl`.\n\nThe stats page only provides current metrics and a few aggregations. Graphite\n(via `--graphite`) or OpenMetrics (via `--stats-bind` then `\\metrics`) should\nbe used if you want a full history.\n\nSome examples of Prometheus query (Grafana variant):\n\n```\nInbound bandwith:\nrate(moproxy_proxy_server_bytes_rx_total[$__range])\n\nTotal outbound traffic:\nsum(increase(moproxy_proxy_server_bytes_tx_total[$__range]))\n\nNo. of connection errors per minute:\nsum(increase(moproxy_proxy_server_connections_error[1m]))\n\nAverage delay for each proxy server:\navg_over_time(moproxy_proxy_server_dns_delay_seconds[$__interval])\n```\n\n### Systemd integration\n\nSample service file: [conf/moproxy.service](conf/moproxy.service)\n\nImplemented features:\n\n- Watchdog\n- Reloading (via SIGHUP signal)\n- Notify (`type=notify`, reloading, status string)\n\nGet simple status without turing on the HTTP stats page:\n\n```\n$ systemctl status moproxy\n\u003e ...\n\u003e Status: \"serving (7/11 upstream proxies up)\"\n\u003e ...\n```\n\n## Install\n\nYou may download the binary executable file on\n[releases page](https://github.com/sorz/moproxy/releases).\n\nArch Linux user can install it from\n[AUR/moproxy](https://aur.archlinux.org/packages/moproxy/).\n\nOr compile it manually:\n\n```bash\n# Install Rust\ncurl https://sh.rustup.rs -sSf | sh\n\n# Clone source code\ngit clone https://github.com/sorz/moproxy\ncd moproxy\n\n# Build\ncargo build --release\ntarget/release/moproxy --help\n\n# If you are in Debian\ncargo install cargo-deb\ncargo deb\nsudo dpkg -i target/debian/*.deb\nmoproxy --help\n```\n\nRefer to [conf/](conf/) for config \u0026 systemd service files. \n","funding_links":["https://patreon.com/xierch"],"categories":["Rust","\u003ca id=\"d03d494700077f6a65092985c06bf8e8\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"57b8e953d394bbed52df2a6976d98dfa\"\u003e\u003c/a\u003eSocks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorz%2Fmoproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorz%2Fmoproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorz%2Fmoproxy/lists"}