Skip to content

Instantly share code, notes, and snippets.

@petrosagg
Created September 14, 2015 15:29
Show Gist options
  • Select an option

  • Save petrosagg/c049e96de629ae0eb42c to your computer and use it in GitHub Desktop.

Select an option

Save petrosagg/c049e96de629ae0eb42c to your computer and use it in GitHub Desktop.
ppp over binary.js
<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>
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);
});
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