0

I have a node app that I want to use as a whitelist for a server of mine. My server accepts udp messages. What I want to do is have some sort of white list that only allows specific ip's to reach the server. I've written a rest api that can add remove and get the whitelist however I'm kinda stuck on how to make node "redirect" the udp packets like we can with a rest request.

const udp = require('dgram');
//Udp client
var client = udp.createSocket('udp4');

client.on('message',function(msg,info){
    console.log('Data received from server : ' + msg.toString());
    console.log('Received %d bytes from %s:%d\n', msg.length, info.address, info.port);
    
    if (whitelist.hosts.includes(info.address))
    {
        //pass on the packets
    }
    else
    {
        //reject connection
        }
});

I've attached the piece of code responsible for getting udp messages, I'd appreciate any input on how I could handle this.

Mr.Grease
  • 197
  • 1
  • 13

0 Answers0