{"id":20429489,"url":"https://github.com/shawwwn/uProxy","last_synced_at":"2025-05-08T17:32:26.778Z","repository":{"id":214720977,"uuid":"737200221","full_name":"shawwwn/uProxy","owner":"shawwwn","description":"An asyncio-based, memory-efficient HTTP/HTTPS/SOCKS4/SOCKS5 forward proxy server for MicroPython, compatible with CPython","archived":false,"fork":false,"pushed_at":"2024-01-16T21:41:02.000Z","size":79,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T05:09:42.435Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/shawwwn.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":"2023-12-30T06:44:36.000Z","updated_at":"2024-12-11T21:51:14.000Z","dependencies_parsed_at":"2024-01-01T08:29:31.207Z","dependency_job_id":"0df250e6-0173-423a-9d34-a3594512780d","html_url":"https://github.com/shawwwn/uProxy","commit_stats":null,"previous_names":["shawwwn/uproxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shawwwn%2FuProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shawwwn%2FuProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shawwwn%2FuProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shawwwn%2FuProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shawwwn","download_url":"https://codeload.github.com/shawwwn/uProxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253114697,"owners_count":21856551,"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":[],"created_at":"2024-11-15T08:00:56.815Z","updated_at":"2025-05-08T17:32:26.770Z","avatar_url":"https://github.com/shawwwn.png","language":"Python","readme":"# µProxy\nA minimal, memory-efficient HTTP/HTTPS/SOCKS4/SOCKS5 proxy server designed to run in memory-constraint environments.\\\nOriginally written for MicroPython, now compatible with CPython.\n\n## Features\n* HTTP(S) protocol (GET/POST/CONNECT/...)\n* SOCKS4(a) protocol (CONNECT/BIND)\n* SOCKS5(h) protocol (CONNECT/BIND/UDP_ASSOCIATE)\n* Maximum connection limit\n* Modular architecture\n* CPython-compatiable\n\n## Usage (MicroPython):\n\n```py\nimport asyncio\nimport uproxy\n\n# Run a HTTP(S) proxy server at port 8765\nproxy = uproxy.uHTTP(ip='0.0.0.0', port=8765)\nasyncio.run(proxy.run())\n```\n\nChange `uHTTP` into `uSOCKS4` or `uSOCKS5` if you want a SOCKS proxy.\n\n## Usage (CPython):\n\n`cproxy.py` is a CPython-compatible wrapper of `uproxy.py` for running uproxy in console.\n\n```\ncproxy.py [-h] [-v] [--proto PROTO] [--ip IP] [--port PORT] [--bind BIND]\n          [--bufsize BUFSIZE] [--maxconns N] [--backlog M]\n          [--timeout TIMEOUT] [--loglevel LOGLEVEL]\n          [--auth AUTH] [--upstream UPSTREAM]\n```\n\nAvailable values for argument `--proto` are `HTTP`,`SOCKS4`, and `SOCKS5`. \\\nRest of the arguments' values are the same as in [api docs](#api-docs).\n\n```console\n$ python3 cproxy.py --proto HTTP --ip 0.0.0.0 --port 8765\nListening on 0.0.0.0:8765\nCONNECT 192.168.1.230:54309     ==\u003e     ifconfig.me:443\nGET     192.168.1.230:54312     ==\u003e     ifconfig.me:80\nCONNECT 192.168.1.230:54315     ==\u003e     www.google.com:443\n```\n\nTo use `cproxy.py` in code:\n\n```py\nimport asyncio\nimport cproxy\nproxy = cproxy.uHTTP()\nasyncio.run(proxy.run())\n```\n\n## API docs:\n\n* **`uproxy.uHTTP(ip='0.0.0.0', port=8765, bind=None, bufsize=8192, maxconns=0, backlog=100, timeout=30, ssl=None, loglevel=1, acl_callback=None, auth=None, upstream=None)`**\n\n  Initialize proxy server\n\n  * **ip** - server ip\n  * **port** - server port\n  * **bind** - ip address for outgoing connections to bind to\n  * **bufsize** - buffer size of each connection, in bytes\n  * **maxconns** - max number of ***accepted*** connections server can handle, 0 to disable\n  * **backlog** - max number of ***unaccepted*** connections waiting to be processed\n  * **timeout** - connection timeout, in seconds\n  * **loglevel** - log level (0-quiet, 1-info, 2-debug)\n  * **ssl** - a SSLContext object to start a HTTPS server\n  * **acl_callback** - access control callback function\n  * **auth** - an 'user:password' pair that clients need to provide in order to authenticate with server\n  * **upstream** - an 'ip:port' pair to connect to as an upstream proxy\n\n* **`uHTTP.run()`**\n\n  Start proxy server.\\\n  Need to run in an asyncio event loop\n\n* **`uHTTP.acl_callback`**\n\n  The access control callback function takes a 4-tuple input (source ip/port and destination ip/port).\\\n  Return `True` to allow current connection to pass, return `False` to block it.\\\n  Default value `None` means always allow all connection to pass.\n  ```py\n  def acl_callback(src_ip: str, src_port: int, dst_ip: str, dst_port: int) -\u003e bool\n  ```\n\n* **`uproxy.SOCKS4(...)`**\n\n  * **auth** - an 'username' term (no colon) because socks4 does not support password\n\n  Same as `uHTTP`\n\n* **`uproxy.SOCKS5(...)`**\n\n  Same as `uHTTP`\n\n## Notes:\n\n+ To use it with MicroPython, only copy `uproxy/` directory.\n+ To use it with CPython, copy both the directory and `cproxy.py`, start with the file.\n+ When you are copying the module's directory, exclude `\u003cprotocol_name\u003e.py` from directory if you have no use for it (e.g. remove `socks4.py` from `uproxy/` so to go without SOCKS4 support). This helps reduce code size.\n+ `cproxy.py` replaces some core logic of `uproxy.py`, making it run much faster, at the expense of 2x memory consumption.\n+ The `upstream` parameter only forwards traffic to an upstream proxy with the same protocol. Mixing protocols is not supported.\n+ A good set of paramters for uproxy to run in a memory-constraint environment should be `maxconns=10, backlog=5, bufsize=512, timeout=5`.\n+ For detail usage, please refer to `examples/`\n\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshawwwn%2FuProxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshawwwn%2FuProxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshawwwn%2FuProxy/lists"}