Last active
February 22, 2020 07:17
-
-
Save mgttt/56974fb371405afaaf160680f80fe09f to your computer and use it in GitHub Desktop.
simple port2port mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const argv2o=a=>(a||process.argv||[]).reduce((r,e)=>((m=e.match(/^(\/|--?)([\w-]*)="?(.*)"?$/))&&(r[m[2]]=m[3]),r),{}); | |
const argo = argv2o(); | |
const net = require('net'); | |
net.createServer(from=>{ | |
var to = net.createConnection({host:argo.to_host,port:argo.to_port}); | |
from.pipe(to).on('error',err=>console.log('from/to',err)); | |
to.pipe(from).on('error',err=>console.log('to/from',err)); | |
}).on('error',err=>console.log(err)).listen(argo.from_port,argo.from_host||'0.0.0.0'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node proxy /to_host= /to_port= /from_port