2
0
mirror of https://git.coolaj86.com/coolaj86/proxy-packer.js.git synced 2025-03-13 20:10:36 +00:00
proxy-packer.js/README.md

54 lines
1.3 KiB
Markdown
Raw Normal View History

2016-12-30 02:41:16 -07:00
<!-- BANNER_TPL_BEGIN -->
2016-12-30 02:23:09 -07:00
About Daplie: We're taking back the Internet!
2016-11-25 10:38:27 -07:00
--------------
2016-12-30 02:23:09 -07:00
Down with Google, Apple, and Facebook!
We're re-decentralizing the web and making it read-write again - one home cloud system at a time.
Tired of serving the Empire? Come join the Rebel Alliance:
2016-11-25 10:38:27 -07:00
2016-12-30 02:23:09 -07:00
<a href="mailto:jobs@daplie.com">jobs@daplie.com</a> | [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-11-25 10:38:27 -07:00
2016-12-30 02:41:16 -07:00
<!-- BANNER_TPL_END -->
2016-11-25 10:38:27 -07:00
2016-09-22 12:59:33 -06:00
# tunnel-packer
2016-10-06 16:03:56 -06:00
2016-09-22 12:59:33 -06:00
A strategy for packing and unpacking tunneled network messages (or any stream) in node.js
2016-10-06 16:03:56 -06:00
Examples
2016-11-29 17:19:54 -07:00
```js
2016-10-06 16:03:56 -06: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'
});
```