Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hex7c0/prerouting
preroute incoming traffic to another TCP server for Nodejs
https://github.com/hex7c0/prerouting
nodejs routing
Last synced: 27 days ago
JSON representation
preroute incoming traffic to another TCP server for Nodejs
- Host: GitHub
- URL: https://github.com/hex7c0/prerouting
- Owner: hex7c0
- License: gpl-3.0
- Created: 2015-01-24T17:00:28.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T00:07:12.000Z (8 months ago)
- Last Synced: 2024-11-23T02:29:48.135Z (about 1 month ago)
- Topics: nodejs, routing
- Language: JavaScript
- Homepage: https://github.com/hex7c0/prerouting
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [prerouting](https://github.com/hex7c0/prerouting)
[![NPM version](https://img.shields.io/npm/v/prerouting.svg)](https://www.npmjs.com/package/prerouting)
[![Linux Status](https://img.shields.io/travis/hex7c0/prerouting.svg?label=linux)](https://travis-ci.org/hex7c0/prerouting)
[![Dependency Status](https://img.shields.io/david/hex7c0/prerouting.svg)](https://david-dm.org/hex7c0/prerouting)
[![Coveralls](https://img.shields.io/coveralls/hex7c0/prerouting.svg)](https://coveralls.io/r/hex7c0/prerouting)Preroute incoming traffic to N TCP servers; for compress data, encrypt message, etc (or just a loop :D)
```
request
|
+
+----------------+
| 5001 -> 5000 |
+----------------+
+
|
compression
|
+
+----------------+
| 5000 -> 3000 |
+----------------+
+
|
decompression
|
+
+----------------+
| 3000 |
+----------------+
```## Installation
Install through NPM
```bash
npm install prerouting
```
or
```bash
git clone git://github.com/hex7c0/prerouting.git
```## API
inside nodejs project
```js
var prerouting = require('prerouting');var server = prerouting.createServer();
```### createServer(options)
#### options
- `toPort` - **Number** connect to this port *(default "3000")*
- `toHost`- **String** connect to this host *(default "127.0.0.1")*
- `listenPort` - **Number** open a TCP server on this port *(default "5000")*
- `listenHost` - **String** open a TCP server on this host *(default "127.0.0.1")*
- `dataToNext` - **Function** function to next route *(default "false")*
- `dataFromNext` - **Function** function from next route *(default "false")*
- `tls` - **Object** Enable TLS server *(default "false")*
- `clientUseTls` - **Boolean** connect to TLS client *(default "false")*NET [options](https://nodejs.org/api/net.html#net_net_createserver_options_connectionlistener)
TLS [options](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
## Examples
Take a look at my [examples](examples)
### [License GPLv3](LICENSE)