{"id":23466103,"url":"https://github.com/hzyitc/mnh","last_synced_at":"2025-04-14T11:42:40.276Z","repository":{"id":43218877,"uuid":"369818255","full_name":"hzyitc/mnh","owner":"hzyitc","description":"A NAT hole punching tool that allows peers directly connect to your NATed server without client. 一个对端不需要客户端就可以直接连接的NAT打洞工具","archived":false,"fork":false,"pushed_at":"2022-10-25T17:22:28.000Z","size":52,"stargazers_count":52,"open_issues_count":1,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T00:51:16.198Z","etag":null,"topics":["go","hole-punching","nat","p2p","tcp","tunnel","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hzyitc.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}},"created_at":"2021-05-22T13:43:04.000Z","updated_at":"2024-11-25T16:02:11.000Z","dependencies_parsed_at":"2022-09-26T19:52:51.660Z","dependency_job_id":null,"html_url":"https://github.com/hzyitc/mnh","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/hzyitc%2Fmnh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hzyitc%2Fmnh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hzyitc%2Fmnh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hzyitc%2Fmnh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hzyitc","download_url":"https://codeload.github.com/hzyitc/mnh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248875263,"owners_count":21176024,"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":["go","hole-punching","nat","p2p","tcp","tunnel","udp"],"created_at":"2024-12-24T11:53:43.385Z","updated_at":"2025-04-14T11:42:40.246Z","avatar_url":"https://github.com/hzyitc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mnh\n[![GitHub release](https://img.shields.io/github/v/tag/hzyitc/mnh?label=release)](https://github.com/hzyitc/mnh/releases)\n\n[README](README.md) | [中文文档](README_zh.md)\n\n**!!! Note: `mnh` is currently in development, the `APIs` and `command line options` may not be backward compatible !!!**\n\n## Introduction\n\n`mnh` is a tool that makes exposing a port behind NAT possible.\n\n`mnh` will produce an `ip:port` pair for your NATed server which can be used for public access.\n\n```\n--------------------------------\n| Help Server (NOT behind NAT) |  \u003c------(query for ip:port pair)-------------\n--------------------------------                                             |\n        ^                                                                    |\n        |                                                                    |\n        |       ---------(Use some way to send ip:port pair)-------------    |\n        |       |                                                       | or |\n        |       |                                                       ↓    |\n------------------------                  ~~~~~~~~~~~~                ----------\n| Service (behind NAT) |    \u003c--------     { Internet }   \u003c----------  | Guests |\n------------------------                  ~~~~~~~~~~~~                ----------\n```\n\n## Usage\n\n### Pre-requests\n\n* Your server's network type should be [Full-cone NAT](https://en.wikipedia.org/wiki/Network_address_translation#Methods_of_translation).\n  \u003e If you don't known what it means, no worries, just continue.\n\n* If your server is behind a firewall or a household router, you probably need to enable [UPnP](https://en.wikipedia.org/wiki/Universal_Plug_and_Play) or do a [port forwarding](https://en.wikipedia.org/wiki/Port_forwarding) to your server on your router since they may block all incoming traffics.\n\n### Setup up a Help server\n\nPlease check [mnh_server](https://github.com/hzyitc/mnh_server).\n\n\u003e Only `mnhv1` protocol is currently supported, more protocols will be added in the future, such as [STUN](https://en.wikipedia.org/wiki/STUN).\n\n### Run mnh\n\n```\nUsage:\n  mnh {tcp|udp} --server \u003cserver\u003e [flags]\n\nFlags:\n  -s, --server string    Help server address(Example: \"server.com\", \"server.com:6641\")\n                           If only specify hostname, it will try SRV resolve.\n                           If SRV failed, it will use default port(6641).\n  -i, --id string        A unique id to identify your machine\n\n  -m, --mode string      Run mode.\n                           TCP support: demoWeb proxy (default \"demoWeb\")\n                           UDP support: demoEcho proxy (default \"demoEcho\")\n  -p, --port int         The local hole port which incoming traffics access to\n  -t, --service string   Target service address. Only need in proxy mode (default \"127.0.0.1:80\")\n\n  -r, --routerForward    A comma-split list which will be used sequentially to request router to do port forwarding (default: \"upnp,notice\")\n                           upnp: UPnP protocol\n                           notice: Will notice you to do port forwarding manually\n                           none: Do port forwarding manually\n\n  -x, --event-hook       Execute command when event triggered:\n                           escape:\n                             %%: percent sign\n                             %e: Event: connecting fail success disconnected\n                             %m: Error message\n                             %p: Local hole port\n                             %a: Hole addr\n\n  -h, --help             help for mnh\n```\n\nExample:\n\nRun a Web server for test:\n\n```\n./mnh tcp --server server.com --id test\n```\n\nRun a UDP Echo server for test:\n\n```\n./mnh udp --server server.com --id udpEcho --mode demoEcho\n```\n\nExpose a local web server:\n\n```\n./mnh tcp --server server.com --id web --mode proxy --service 127.0.0.1:80\n```\n\n`mnh` will attempt to request router to do port forwarding with `upnp` protocol by default.\n\nIf failed, it will show a `notice`. \n\nYou can disable these two functions by set `--routerForward none`, make sure you have set up port forwarding correctly.\n(See [Pre-requests](#pre-requests))\n\n```\n./mnh tcp --server server.com --id web --mode proxy --service 127.0.0.1:80 --port 8888 --routerForward none\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhzyitc%2Fmnh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhzyitc%2Fmnh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhzyitc%2Fmnh/lists"}