项目作者: anzerr

项目描述 :
Tunnel a tcp connection
高级语言: JavaScript
项目地址: git://github.com/anzerr/tcp.proxy.git
创建时间: 2019-04-30T11:02:46Z
项目社区:https://github.com/anzerr/tcp.proxy

开源协议:MIT License

下载


Intro

GitHub Actions status | publish

Tunnel a tcp connection to a remote socket and listen/edit the traffic through the tunnel.

Install

  1. npm install --save git+https://github.com/anzerr/tcp.proxy.git
  2. npm install --save @anzerr/tcp.proxy

Example

  1. const Proxy = require('tcp.proxy');
  2. let p = new Proxy('localhost:5670', 'localhost:5671');
  3. p.on('connect', (tunnel) => {
  4. tunnel.on(Proxy.RX, (data, resolve) => {
  5. console.log(Proxy.RX, tunnel.key, data.toString());
  6. resolve(data);
  7. }).on(Proxy.TX, (data, resolve) => {
  8. console.log(Proxy.TX, tunnel.key, data.toString());
  9. resolve(data);
  10. }).on('close', () => {
  11. console.log('tunnel closed', tunnel.key);
  12. });
  13. });