{"id":15283774,"url":"https://github.com/nobles5e/cproxy","last_synced_at":"2025-05-15T00:07:19.973Z","repository":{"id":36970564,"uuid":"341781100","full_name":"NOBLES5E/cproxy","owner":"NOBLES5E","description":"Easy per application transparent proxy built on cgroup.","archived":false,"fork":false,"pushed_at":"2025-05-05T04:13:41.000Z","size":236,"stargazers_count":431,"open_issues_count":5,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-09T17:58:14.003Z","etag":null,"topics":["proxy","proxychains","shadowsocks","tproxy","transparent-proxy","v2ray"],"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/NOBLES5E.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,"zenodo":null}},"created_at":"2021-02-24T04:42:28.000Z","updated_at":"2025-05-07T06:43:17.000Z","dependencies_parsed_at":"2024-11-12T18:00:35.503Z","dependency_job_id":"57922b39-ebb4-4df6-975c-f95ee0ce8256","html_url":"https://github.com/NOBLES5E/cproxy","commit_stats":{"total_commits":213,"total_committers":2,"mean_commits":106.5,"dds":"0.47887323943661975","last_synced_commit":"6cb6033ca0e2eb2f4625479053f9d795438b3c30"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NOBLES5E%2Fcproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NOBLES5E%2Fcproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NOBLES5E%2Fcproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NOBLES5E%2Fcproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NOBLES5E","download_url":"https://codeload.github.com/NOBLES5E/cproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249197,"owners_count":22039029,"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":["proxy","proxychains","shadowsocks","tproxy","transparent-proxy","v2ray"],"created_at":"2024-09-30T14:47:19.732Z","updated_at":"2025-05-15T00:07:14.964Z","avatar_url":"https://github.com/NOBLES5E.png","language":"Rust","readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"250px\" src=\"https://user-images.githubusercontent.com/18649508/139117888-4f631b07-0b40-4d24-b478-fb805ceef689.png\" /\u003e\n\u003c/p\u003e\n\u003chr/\u003e\n\n[![Crates.io](https://img.shields.io/crates/v/cproxy)](https://crates.io/crates/cproxy) [![CI](https://github.com/NOBLES5E/cproxy/actions/workflows/build.yml/badge.svg)](https://github.com/NOBLES5E/cproxy/actions/workflows/build.yml) ![Crates.io](https://img.shields.io/crates/d/cproxy) ![Crates.io](https://img.shields.io/crates/l/cproxy)\n\nEver wished you could make your stubborn programs use a proxy without them even knowing? Well, say hello to `cproxy`.\n\n## Key Features\n\n- Transparent redirection of TCP and UDP traffic\n- Support for different proxies per application/process\n- Compatible with all programs, including statically linked Go binaries\n- DNS request redirection\n- Simple usage similar to `proxychains`\n- Ability to proxy existing running processes\n- Support for both iptables `REDIRECT` and `TPROXY` modes\n- DNS server override in `TPROXY` mode\n- Network activity tracing using iptables `LOG` target\n- Compatible with cgroup v1 and v2\n- No background daemon required\n- Easy integration with existing software like V2Ray, Xray, and Shadowsocks\n\n\u003e [!TIP]\n\u003e Your proxy should be a transparent proxy port (like V2Ray's `dokodemo-door` inbound or shadowsocks `ss-redir`). But don't panic if you only have a SOCKS5 or HTTP proxy! There are tools that can transform it [faster than Bill Clinton](https://youtu.be/Dv0PxINy2ds?t=570) (check out [transocks](https://github.com/cybozu-go/transocks), [ipt2socks](https://github.com/zfl9/ipt2socks) and [ip2socks-go](https://github.com/lcdbin/ip2socks-go)).\n\n## Installation\n\nYou can install by downloading the binary from the [release page](https://github.com/NOBLES5E/cproxy/releases) or install with: `cargo install cproxy`.\n\nAlternatively, here's a oneliner that downloads the latest release and put it in your `/usr/local/bin/` (for the lazy... I mean, efficient folks):\n\n```\ncurl -s https://api.github.com/repos/NOBLES5E/cproxy/releases/latest | grep \"browser_download_url.*x86_64-unknown-linux-musl.zip\" | cut -d : -f 2,3 | tr -d \\\" | wget -qi - -O /tmp/cproxy.zip \u0026\u0026 unzip -j /tmp/cproxy.zip cproxy -d /tmp \u0026\u0026 sudo mv /tmp/cproxy /usr/local/bin/ \u0026\u0026 sudo chmod +x /usr/local/bin/cproxy \u0026\u0026 rm /tmp/cproxy.zip\n```\n\n## Usage\n\n### Basic Magic Trick: Just Like `proxychains`\n\nYou can launch a new program with `cproxy` with:\n\n```\nsudo cproxy --port \u003cdestination-local-port\u003e -- \u003cyour-program\u003e --arg1 --arg2 ...\n```\n\nAll TCP connections requests will be proxied. If your local transparent proxy support DNS address overriding, you can\nalso redirect DNS traffic with `--redirect-dns`:\n\n```\nsudo cproxy --port \u003cdestination-local-port\u003e --redirect-dns -- \u003cyour-program\u003e --arg1 --arg2 ...\n```\n\nFor an example setup, see [wiki](https://github.com/NOBLES5E/cproxy/wiki/Example-setup-with-V2Ray).\n\n\u003e [!NOTE]\n\u003e Scared of `sudo` in the command? Well, that's what we need to have the permission to modify cgroup. But don't worry too much, the program you run will still be run under your original user, not as root. `cproxy` automatically drops privileges after setting up the necessary cgroup configurations, ensuring that your program runs with the same permissions as if you had launched it directly.\n\n### The TPROXY Twist\n\nIf your system support `tproxy`, you can use `tproxy` with `--mode tproxy`:\n\n```bash\nsudo cproxy --port \u003cdestination-local-port\u003e --mode tproxy -- \u003cyour-program\u003e --arg1 --arg2 ...\n# or for existing process\nsudo cproxy --port \u003cdestination-local-port\u003e --mode tproxy --pid \u003cexisting-process-pid\u003e\n```\n\nWith `--mode tproxy`, there are several differences:\n\n* All UDP traffic are proxied instead of only DNS UDP traffic to port 53.\n* Your V2Ray or shadowsocks service should have `tproxy` enabled on the inbound port. For V2Ray, you\n  need `\"tproxy\": \"tproxy\"` as\n  in [V2Ray Documentation](https://www.v2ray.com/en/configuration/transport.html#sockoptobject). For shadowsocks, you\n  need `-u` as shown in [shadowsocks manpage](http://manpages.org/ss-redir).\n\nAn example setup can be found [here](https://github.com/NOBLES5E/cproxy/wiki/Example-setup-with-V2Ray).\n\nNote that when you are using the `tproxy` mode, you can override the DNS server address\nwith `cproxy --mode tproxy --override-dns \u003cyour-dns-server-addr\u003e ...`. This is useful when you want to use a different\nDNS server for a specific application.\n\n### Advanced Usage: Proxy an Existing Process\n\nWith `cproxy`, you can even proxy an existing process. This is very handy when you want to proxy existing system\nservices such as `docker`. To do this, just run\n\n```\nsudo cproxy --port \u003cdestination-local-port\u003e --pid \u003cexisting-process-pid\u003e\n```\n\nThe target process will be proxied as long as this `cproxy` command is running. You can press Ctrl-C to stop proxying.\n\n### Advanced Usage: Debug a Program's Network Activity with Iptables LOG Target\n\nWith `cproxy`, you can easily debug a program's traffic in netfilter. Just run the program with\n\n```bash\nsudo cproxy --mode trace \u003cyour-program\u003e\n```\n\nYou will be able to see log in `dmesg`. Note that this requires a recent enough kernel and iptables.\n\n### Advanced Usage: Proxy Specific Cgroup Paths\n\n`cproxy` allows you to proxy all processes within specific cgroup paths. This is particularly useful for managing groups of related processes without specifying individual PIDs.\n\nSuppose you have a cgroup at `/sys/fs/cgroup/mygroup` containing several processes you wish to proxy. You can run:\n\n```bash\nsudo cproxy --port 1080 --cgroup-path /sys/fs/cgroup/mygroup --mode tproxy\n```\n\nThis command will proxy all TCP and UDP traffic from processes within the `/sys/fs/cgroup/mygroup` cgroup using TPROXY mode on port `1080`.\n\n## The Secret Sauce\n\n`cproxy` simply creates a unique `cgroup` for the proxied program, and redirect its traffic with packet rules.\n\n## Limitations\n\n* `cproxy` requires root access to modify `cgroup`.\n* Currently only tested on Linux.\n\n## Similar Projects\n\nThere are some awesome existing work:\n\n* [graftcp](https://github.com/hmgle/graftcp): work on most programs, but cannot proxy UDP (such as DNS)\n  requests. `graftcp` also has performance hit on the underlying program, since it uses `ptrace`.\n* [proxychains](https://github.com/haad/proxychains): easy to use, but not working on static linked programs (such as Go\n  programs).\n* [proxychains-ng](https://github.com/rofl0r/proxychains-ng): similar to proxychains.\n* [cgproxy](https://github.com/springzfx/cgproxy): `cgproxy` also uses cgroup to do transparent proxy, and the idea is\n  similar to `cproxy`'s. There are some differences in UX and system requirements:\n    * `cgproxy` requires system `cgroup` v2 support, while `cproxy` works with both v1 and v2.\n    * `cgproxy` requires a background daemon process `cgproxyd` running, while `cproxy` does not.\n    * `cgproxy` requires `tproxy`, which is optional in `cproxy`.\n    * `cgproxy` can be used to do global proxy, while `cproxy` does not intended to support global proxy.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobles5e%2Fcproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnobles5e%2Fcproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobles5e%2Fcproxy/lists"}