Tuesday, April 19, 2011

Protocols #3, Discard

Let's build a discard protocol from Node.js:

RFC 863: "A useful debugging and measurement tool is a discard service. A discard service simply throws away any data it receives."

For the time being, we'll just leave this not logging anything; although in the future we may want to connect this to a UNIX socket to make a honeypot, that fun can come later.

The discard protocol is essentially the same as the echo protocol, except it has blank functions and the ports are changed (the port should really be 9, but unless you are root you aren't allowed to touch low ports).

//An implementation of the discared protocol RFC 863
var net = require('net');
var dgram = require('dgram');

var tcpserver = net.createServer(function(socket) { })
var udpserver = dgram.createSocket("udp4", function(msg, rinfo) { });

//Bind and serve
tcpserver.listen(8009, "127.0.0.1");
udpserver.bind(8009, "127.0.0.1");

No comments:

Post a Comment