proxy-packer.js/README.md

49 lines
1.2 KiB
Markdown
Raw Normal View History

2016-11-25 17:38:27 +00:00
Daplie is Taking Back the Internet!
--------------
[![](https://daplie.github.com/igg/images/ad-developer-rpi-white-890x275.jpg?v2)](https://daplie.com/preorder/)
Stop serving the empire and join the rebel alliance!
* [Invest in Daplie on Wefunder](https://daplie.com/invest/)
* [Pre-order Cloud](https://daplie.com/preorder/), The World's First Home Server for Everyone
2016-09-22 18:59:33 +00:00
# tunnel-packer
2016-10-06 22:03:56 +00:00
2016-09-22 18:59:33 +00:00
A strategy for packing and unpacking tunneled network messages (or any stream) in node.js
2016-10-06 22:03:56 +00:00
Examples
2016-11-30 00:19:54 +00:00
```js
2016-10-06 22:03:56 +00:00
var Packer = require('tunnel-packer');
Packer.create({
onmessage: function (msg) {
// msg = { family, address, port, service, data };
}
, onend: function (msg) {
// msg = { family, address, port };
}
, onerror: function (err) {
// err = { message, family, address, port };
}
});
var chunk = Packer.pack(address, data, service);
var addr = Packer.socketToAddr(socket);
var id = Packer.addrToId(address);
var id = Packer.socketToId(socket);
var myDuplex = Packer.Stream.create(socketOrStream);
var myTransform = Packer.Transform.create({
address: {
family: '...'
, address: '...'
, port: '...'
}
// hint at the service to be used
, service: 'https'
});
```