2.0.2 • Published 4 years ago

simple-tcp-proxy v2.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

NPM

NPM Github Docs Build Status Coverage Status Known Vulnerabilities dependencies Status

Simple TCP Proxy module for NodeJS

Require simple-tcp-proxy

const SimpleTcpProxy = require('simple-tcp-proxy')

Create a proxy with a function

const proxy = new SimpleTcpProxy({proxy:{host:'127.0.0.1', port:25565}, target:{host:'127.0.0.1', port:25566}});
proxy.start(function(server, client){ // optional callback will be called with every new connection
    // object from proxy (tcp server)
    server.on('data',  function(data){
        console.log(data);
    });
    
    // object from client (client to target server)
    client.on('data',  function(data){
        console.log(data);
    });
}, function(error){
    // optional error handler
    console.log(error);
});

console.log(proxy.status); // print proxy status (online/offline)
console.log(proxy.client_con); // print an object with all connections
console.log(proxy.socket) // print proxy server socket

one line proxy

proxy.run({proxy:{host:'127.0.0.1', port:25565}, target:{host:'127.0.0.1', port:25566}})

all scripts in package.json are not available over npm only over github

changed to update 2.0.0

// old (v1.0.0) version (won't work!)
require('simple-tcp-proxy')({proxy: {}, target: {}}, ()=> {}, ()=> {})

// new version
require('simple-tcp-proxy').run({proxy: {}, target: {}}, ()=> {}, ()=> {})

// or with a class
const proxy = new require('simple-tcp-proxy')({proxy: {}, target: {}})
proxy.start()
2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.0

8 years ago