eurocat2k / tcpproxyserver

This little application allows TCP connections for clients to access one specific remote TCP server's service read only or for a dedicated host allows a duplex communication.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tcpproxyserver

This little application allows TCP connections for clients to access one specific remote TCP server's service read only or for a dedicated host allows a duplex communication.

Basic usage

There are several ways to start the application:

  • running directly using node' CLI:
    node tcpproxysrv.js -r <address of remote server> -p <port of remote server> [optional arguments]
  • or using pm2 as follows:
pm2 start tcpproxysrv.js -- -r <address of remote server> -p <port of remote server> [optional arguments]
  • or still using pm2's ecosystem configuration file, we can run as follows:
pm2 start --watch ecosystem.config.js

having the * ecosystem configuration file * generated by pm2 init command, and updated it's content:

contents of * ecosystem.config.js *

module.exports = {
  apps: [{
    name: "TCPPROXYSRV",
    script: "tcpproxysrv.js",
    args: "-r <address of remote server> -p <port of remote server> -o <listening port> -x <maximum number of clients>",
    instances: 1,
    autorestart: true
  }]
};

Calling without any argument, the application will output these info below:

tcpproxysrv.js [-D|--duplex] -r|--remote_server <remote address> -p|--remote_port <remote port> \
                [-l|--local_server <local address>] [-o|--local_port <local port>] \
                [-m|--matias_host <matias TTF dcs address>] [-x|--max_clients <#number>] \
                [-G|--get_conf
                
        Where the mandatory arguments are:

                -r|--remote_server - the remote host where the proxy server connects
                -p|--remote_port   - the remote service which is used by proxy server during connection

        the optional arguments are:

                -D|--duplex        - allows MATIAS host to communicate the remote server in duplex mode. Default is false.
                -l|--local_server  - the server listening address where clients can connect. Default is 0.0.0.0
                -o|--local_port    - the server listening service which is transfered to remote server service port. Default is 8739
                -m|--matias_host   - the address of MATIAS TTF DCS IO VLAN address, in duplex mode two way communication allowed for this host
                -G|--get_conf      - lists default configuration options.
                -x|--max_clients   - maximum number of clients allowed to connect to the proxy server. Default is 32

The main goal was to implement a simple TCP proxy and multiplexer for clients, which work with a data stream from remote server. That server allows only one connection at a time to it's service, and only from one dedicated client. I know there are dozens of brilliant solutions to port forward and multiplex a single data stream to several clients. I choosed this one. I'm working in the Air Traffic Control Center, where several services are available for their dedicated clients and/or servers. One of the example is our new AFTN center. It allows bidirectional communications between the center and the ATC systems including the test rig. However for the latter case, it is advised not to pollute the live system with test messages. Our app does not allow by default to write socket connected to the remote server. If so, it is allowed just for the dedicated host * which is actually our test communication server * but as many other attributes during start time, these variables can be customized as required.

About

This little application allows TCP connections for clients to access one specific remote TCP server's service read only or for a dedicated host allows a duplex communication.

License:MIT License


Languages

Language:JavaScript 100.0%