Created
September 14, 2015 15:29
-
-
Save petrosagg/c049e96de629ae0eb42c to your computer and use it in GitHub Desktop.
ppp over binary.js
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
| <html> | |
| <head> | |
| <script src="binary.js"></script> | |
| <script> | |
| // Connect to Binary.js server of the OpenROV | |
| var openrov = new BinaryClient('ws://openrov.lan:3000'); | |
| openrov.on('stream', function(openrovStream){ | |
| // Connect to Binary.js server of the internet facing OpenROV proxy | |
| var proxy = new BinaryClient('ws://proxy.openrov.com:3000'); | |
| proxy.on('stream', function(proxyStream){ | |
| openrovStream.pipe(proxyStream); | |
| proxyStream.pipe(openrovStream); | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
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
| var spawn = require('child_process').spawn; | |
| var binaryjs = require('binaryjs'); | |
| // Start pppd process. The `notty` makes pppd use its stdin/stdout streams for communication | |
| var pppd = spawn('pppd', [ 'noauth', 'nodetach', 'notty', 'logfd', '2' ]); | |
| pppd.stderr.pipe(process.stderr); | |
| var server = binaryjs.BinaryServer({port: 3000}); | |
| server.on('connection', function(client){ | |
| var stream = client.createStream(); | |
| stream.pipe(pppd.stdin); | |
| pppd.stdout.pipe(stream); | |
| }); |
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
| var spawn = require('child_process').spawn; | |
| var binaryjs = require('binaryjs'); | |
| // Start pppd process. The `notty` makes pppd use its stdin/stdout streams for communication | |
| var pppd = spawn('pppd', [ 'noauth', 'nodetach', 'notty', 'debug', 'logfd', '2', '10.3.0.1:10.3.0.2' ]); | |
| pppd.stderr.pipe(process.stderr); | |
| var server = binaryjs.BinaryServer({port: 3000}); | |
| server.on('connection', function(client){ | |
| var stream = client.createStream(); | |
| stream.pipe(pppd.stdin); | |
| pppd.stdout.pipe(stream); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment