| 
									
										
										
										
											2015-02-08 00:03:39 -05:00
										 |  |  | # holepunch
 | 
					
						
							| 
									
										
										
										
											2015-12-29 19:21:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | A commandline tool (cli) and library (node.js api) for making devices | 
					
						
							|  |  |  | in your home and office Internet-accessible. | 
					
						
							| 
									
										
										
										
											2015-12-29 19:21:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | Uses UPnP / SSDP and NAT-PMP / ZeroConf (Bonjour) for port forwarding / port mapping. | 
					
						
							| 
									
										
										
										
											2015-12-29 19:21:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | Works for IPv4 and IPv6 interfaces. | 
					
						
							| 
									
										
										
										
											2015-12-30 21:40:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | ## Status
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Published as alpha, but nearing release quality. | 
					
						
							| 
									
										
										
										
											2015-12-29 19:21:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 08:22:04 +00:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2015-12-30 21:40:52 +00:00
										 |  |  | git clone git@github.com:Daplie/holepunch.git | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | pushd holepunch | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 08:22:04 +00:00
										 |  |  | node bin/holepunch.js --debug | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 21:40:52 +00:00
										 |  |  | ## Install
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | **Commandline Tool** | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | npm install --global holepunch | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | **node.js Library** | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | npm install --save holepunch | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | ## Examples
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | Some examples that work with what's currently published. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | ### Commandline (CLI)
 | 
					
						
							| 
									
										
										
										
											2015-12-30 21:40:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | holepunch --help | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | holepunch --plain-ports 80,65080 --tls-ports 443,65443 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | ### API
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 02:21:29 +00:00
										 |  |  | This is the current Dec 30th api in master | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | ```javascript | 
					
						
							|  |  |  | var punch = require('holepunch'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | punch({ | 
					
						
							|  |  |  |   debug: true | 
					
						
							| 
									
										
										
										
											2015-12-31 02:21:29 +00:00
										 |  |  | , mappings: [{ internal: 443, external: 443, secure: true }] | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | , ipifyUrls: ['api.ipify.org'], | 
					
						
							|  |  |  | , protocols: ['none', 'upnp', 'pmp'] | 
					
						
							|  |  |  | , rvpnConfigs: [] | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | }).then(function (mappings) { | 
					
						
							|  |  |  |   // be sure to check for an `error` attribute on each mapping | 
					
						
							|  |  |  |   console.log(mappings); | 
					
						
							|  |  |  | }, function (err) { | 
					
						
							|  |  |  |   console.log(err); | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | }); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  | ## API (v1.0.0 draft)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TODO: This is the api that I think I'd like to use for the solid v1.0.0 | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```javascript | 
					
						
							|  |  |  | punch(opts) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  |   opts.debug = true | false     // print extra debug info | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   opts.mappings = [             // these ports will be tested via tcp / http | 
					
						
							|  |  |  |     { internal: 80              // the port which is bound locally | 
					
						
							|  |  |  |     , external: 80              // the port as it is exposed on the internet | 
					
						
							|  |  |  |     , loopback: true | false    // whether or not to attempt an http(s) loopback test | 
					
						
							|  |  |  |     , secure: true | false      // (default: true) whether to use tls or plaintext | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   opts.ipifyUrls = [            // ipify urls | 
					
						
							|  |  |  |     'api.ipify.org'             // default | 
					
						
							|  |  |  |   ] | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  |   opts.upnp = true | false      // attempt mapping via nat-upnp | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  |   opts.pmp = true | false       // attempt mapping via nat-pmp | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 00:27:48 +00:00
										 |  |  |   opts.rvpnConfigs = [ | 
					
						
							|  |  |  |     '/etc/holepunch/rvpn.json'  // TODO (not implemented) | 
					
						
							|  |  |  |   ] | 
					
						
							| 
									
										
										
										
											2015-12-30 23:13:06 +00:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Commandline
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 21:40:52 +00:00
										 |  |  | TODO `--prebound-ports 22` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | Usage: | 
					
						
							|  |  |  |   holepunch.js [OPTIONS] [ARGS] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Options: | 
					
						
							|  |  |  |       --debug BOOLEAN       show traces and logs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       --plain-ports STRING  Port numbers to test with plaintext loopback. | 
					
						
							|  |  |  |                             (default: 65080) | 
					
						
							|  |  |  |                             (formats: <port>,<internal:external>) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       --tls-ports STRING    Port numbers to test with tls loopback. | 
					
						
							|  |  |  |                             (default: null) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       --ipify-urls STRING   Comma separated list of URLs to test for external ip. | 
					
						
							|  |  |  |                             (default: api.ipify.org) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       --protocols STRING    Comma separated list of ip mapping protocols. | 
					
						
							|  |  |  |                             (default: none,upnp,pmp) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       --rvpn-configs STRING Comma separated list of Reverse VPN config files in | 
					
						
							|  |  |  |                             the order they should be tried. (default: null) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   -h, --help                Display help and usage details | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-30 22:35:17 +00:00
										 |  |  | ## Non-Root
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You **do not need root** to map ports, but you may need root to test them. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If you're cool with allowing all node programs to bind to privileged ports, try this: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-29 19:21:11 +00:00
										 |  |  | # License
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MPL-2.0 |