1.0.12 • Published 5 years ago

kr-udp-proxy v1.0.12

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

What is This?

UDP proxy server library with Worker-Thread
Worker-Thread opens server and dupplicates message to Main Thread
So.. It cannot modifies data but Asynchronous!
It ONLY supports IPv4
It will keeps same port during 10secs

// TypeScript

import udpproxy = require('kr-udp-proxy');

class Client implements udpproxy.Client
{
    clientId:number; // undefined in constructor
    address:string; // undefined in constructor
    port:number; // undefined in constructor

    connected()
    {
    }

    message(origin:udpproxy.Origin, msg:Buffer)
    {
        /*
        // if sync option is true
        return null; // remove packet
        return Buffer.alloc(1); // modify packet
        */
    
        switch (origin)
        {
        case udpproxy.Origin.Server:
            console.log(`Server to ${this.address}:${this.port}> ${msg.toString('utf-8')}`);
            break;
        case udpproxy.Origin.Client:
            console.log(`${this.address}:${this.port} to Server> ${msg.toString('utf-8')}`);
            break;
        }
    }


    disconnected()
    {
    }
}

udpproxy.bind(()=>new Client, {
    // fromAddress: '0.0.0.0', 
    fromPort: 19134, 
    toAddress: '127.0.0.1', 
    toPort: 19132,
    // keepPortTimeout: 10000,
    // sync: false,
    // onError: err=>{ console.error(err); }
});
1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago