{"id":21215437,"url":"https://github.com/choueric/depot","last_synced_at":"2025-03-15T00:25:08.312Z","repository":{"id":75763958,"uuid":"118574471","full_name":"choueric/depot","owner":"choueric","description":"Proxy program using socks5","archived":false,"fork":false,"pushed_at":"2018-02-08T08:55:22.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T16:31:40.379Z","etag":null,"topics":["golang","socks5-proxy","tunnel"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/choueric.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":"2018-01-23T07:31:01.000Z","updated_at":"2018-02-08T08:57:09.000Z","dependencies_parsed_at":"2023-03-08T06:15:35.642Z","dependency_job_id":null,"html_url":"https://github.com/choueric/depot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choueric%2Fdepot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choueric%2Fdepot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choueric%2Fdepot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choueric%2Fdepot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choueric","download_url":"https://codeload.github.com/choueric/depot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243664633,"owners_count":20327513,"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":["golang","socks5-proxy","tunnel"],"created_at":"2024-11-20T21:38:36.084Z","updated_at":"2025-03-15T00:25:08.283Z","avatar_url":"https://github.com/choueric.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# depot\n\nProxy program using socks5 to create tunnel between client application and your \ninternal net host. For example, it's useful for connecting the transmission\non your host NAS by transmission-remote-gui on anywhere, as shown below:\n\n```\n--- client ---+------- server -------+------- local ------------------\n\nclient \u003c--[socks5]--\u003e depot-server \u003c---\u003e depot-local \u003c--[localhost]--\u003e app\n```\n\nOnce the socks connection is established, the reqeust of `client` must be sent to\naddress `127.0.0.1:port` via this connection and it will be transferred to `app`\neventually. It seems `client` is communicating with `app` directly.\n\n# Features\n\n* Web interface to wathch status of connections.\n* Socks5 connection (username/no-username)\n\n# Internal\n\n## connections\n\n- control connection\n  - connect server and local\n  - send socks request from server to local\n  - send alive message from local to server\n- socks connection\n  - connect client and server\n  - send socks request from client to server\n  - for pipe\n- tunnel connection\n  - connect server and local\n  - for pipe\n- app connection\n  - connect local and app\n  - for pipe\n\n## process\n\n1. Server listens on the control port and socks port.\n```\n   +---+\n   | C |\n   +---+\n   +---+\n   | S |\n   +---+\n```\n\n2. Local connects to the control port, and establish a control connection by\n   handshaking. Local will wait for socks request on this connection.\n   l-\u003ec: \"hello server\"\n   c-\u003el: \"hello local\"\n```\n   +---+\n   | C |\n   +---+\n      +-+      handshake      +-+\n      |c|\u003c-------------------\u003e|l|\n      +-+      [ctrlConn]     +-+\n   +---+\n   | S |\n   +---+\n```\n   \n3. Server listens on the tunnel port, and waits for socks request.\n```\n   +---+\n   | C |\n   +---+\n      +-+                     +-+\n      |c|\u003c-------------------\u003e|l|\n      +-+      [ctrlConn]     +-+\n   +---+\n   | S |\n   +---+\n   +---+\n   | T |\n   +---+\n```\n   \n4. Client connects to the socks port and establish an socks connection after \n   handshaking and authenticating.\n```\n                           +---+\n                           | C |\n                           +---+\n                              +-+                     +-+\n                              |c|\u003c-------------------\u003e|l|\n                              +-+      [ctrlConn]     +-+\n                           +---+\n                           | S |\n                           +---+\n    +-+  handshake/auth   +-+\n    |r|\u003c-----------------\u003e|s|\n    +-+   [socksConn]     +-+\n                           +---+\n                           | T |\n                           +---+\n```\n \n5. Client sends the socks request to server. Server validates the request and \n   send it to local via control connection.\n```\n                           +---+\n                           | C |\n                           +---+\n                              +-+   2.socks request   +-+\n                              |c|\u003c-------------------\u003e|l|\n                              +-+     [ctrlConn]      +-+\n                           +---+\n                           | S |\n                           +---+\n    +-+  1.socks request  +-+\n    |r|\u003c-----------------\u003e|s|\n    +-+   [socksConn]     +-+\n                           +---+\n                           | T |\n                           +---+\n```\n\t\n6. Local parses the socks request and open an app connection to the target \n   host:port (i.e. app). After that, local sends success reply to server, and\n   server sends reply to client.\n```\n                           +---+\n                           | C |\n                           +---+\n                              +-+     2.reply         +-+\n                              |c|\u003c-------------------\u003e|l|\n                              +-+     [ctrlConn]      +-+\n                           +---+                      +-+   1.connect   +-+\n                           | S |                      |b|\u003c-------------\u003e|a|\n                           +---+                      +-+   [appConn]   +-+\n    +-+    3.reply        +-+\n    |r|\u003c-----------------\u003e|s|\n    +-+   [socksConn]     +-+\n                           +---+\n                           | T |\n                           +---+\n```\n   \n7. Local connects to the tunnel port of server and establishs the tunnel\n   connection by sending the socks request back as a handshake.\n```\n                           +---+\n                           | C |\n                           +---+\n                              +-+                     +-+\n                              |c|\u003c-------------------\u003e|l|\n                              +-+     [ctrlConn]      +-+\n                           +---+                      +-+               +-+\n                           | S |                      |b|\u003c-------------\u003e|a|\n                           +---+                      +-+   [appConn]   +-+\n    +-+                   +-+\n    |r|\u003c-----------------\u003e|s|\n    +-+   [socksConn]     +-+\n                           +---+\n                           | T |\n                           +---+\n\t\t\t\t\t\t      +-+  connect/handshake  +-+\n\t\t\t\t\t\t\t  |t|\u003c-------------------\u003e|d|\n\t\t\t\t\t\t      +-+     [tunnelConn]    +-+\n```\n\n8. At this time, all necessary connetions are already established. Pipe them\n   together (s\u0026t, d\u0026b) and the connection between client and app will work\n   well. Client can communicate with app with socket r.\n```\n                           +---+\n                           | C |\n                           +---+\n                              +-+       alive         +-+\n                              |c|\u003c-------------------\u003e|l|\n                              +-+      [ctrlConn]     +-+\n                           +---+                        \n                           | S |                        \n                           +---+                        \n    +-+                   +-+ +-+                   +-+ +-+                +-+\n    |r|\u003c-----------------\u003e|s|-|t|\u003c-----------------\u003e|d|-|b|\u003c--------------\u003e|a|\n    +-+   [socksConn]     +-+ +-+     [tunnelConn]  +-+ +-+    [appConn]   +-+\n                           +---+\n                           | T |\n                           +---+\n```\n\nThe final pipeline is:\n\n```\n         socksConn \u003c--\u003e tunnelConn \u003c--\u003e appConn\n```\n\nThe ctrlConn is used by local to send alive message. And once local exits, this\nconnection would be closed. In the other hand, once server exits, local should\nclose all connections and try to connect to control port of server again and\nagain.\n\n# TODO\n\n- [X] local should try to connect to server repeatly and send heartbeat message\n      to server after connecting.\n- [X] provide methods to watch the status of server and local.\n- [ ] how to handle multiple socks reqeusts?\n\n# License\n\nSee the `LICENSE` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoueric%2Fdepot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoueric%2Fdepot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoueric%2Fdepot/lists"}