From 5ed98e33a103c11d0e376d29650c083dbd6ceab4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 28 Aug 2012 06:49:51 -0400 Subject: [PATCH] The -t option goes way; we listen on both TCP and UDP. --- irker.py | 32 ++++++++++---------------------- irker.xml | 17 +++++------------ 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/irker.py b/irker.py index 5f95a2f..792ee16 100755 --- a/irker.py +++ b/irker.py @@ -12,16 +12,11 @@ a list of such strings; in the latter case the message is broadcast to all listed channels. Note that the channel portion of the URL will *not* have a leading '#' unless the channel name itself does. -Message transmission is normally via UDP, optimizing for lowest -latency and network load by avoiding TCP connection setup time; the -cost is that delivery is not reliable in the face of packet loss. -The -t option changes this, telling the daemon to use TCP instead. - -Other options: -p sets the listening port, -n sets the name suffix -for the nicks that irker uses. The default suffix is derived from the -FQDN of the site on which irker is running; the intent is to avoid -nick collisions by instances running on different sites. The -V -option prints the program version and exits. +Options: -p sets the listening port, -n sets the name suffix for the +nicks that irker uses. The default suffix is derived from the FQDN of +the site on which irker is running; the intent is to avoid nick +collisions by instances running on different sites. The -V option +prints the program version and exits. Requires Python 2.6 and the irc.client library: see @@ -242,8 +237,7 @@ if __name__ == '__main__': port = PORT namesuffix = None debuglevel = 0 - tcp = False - (options, arguments) = getopt.getopt(sys.argv[1:], "d:p:n:t:V") + (options, arguments) = getopt.getopt(sys.argv[1:], "d:p:n:V") for (opt, val) in options: if opt == '-d': # Enable debug/progress messages debuglevel = int(val) @@ -253,19 +247,13 @@ if __name__ == '__main__': port = int(val) elif opt == '-n': # Set the name suffix for irker nicks namesuffix = val - elif opt == '-t': # Use TCP rather than UDP - tcp = True elif opt == '-V': # Emit version and exit sys.stdout.write("irker version %s\n" % version) sys.exit(0) irker = Irker(debuglevel=debuglevel, namesuffix=namesuffix) - if tcp: - server = SocketServer.TCPServer((host, port), IrkerTCPHandler) - else: - server = SocketServer.UDPServer((host, port), IrkerUDPHandler) - try: - server.serve_forever() - except KeyboardInterrupt: - pass + tcpserver = SocketServer.TCPServer((host, port), IrkerTCPHandler) + udpserver = SocketServer.UDPServer((host, port), IrkerUDPHandler) + threading.Thread(target=tcpserver.serve_forever).start() + threading.Thread(target=udpserver.serve_forever).start() # end diff --git a/irker.xml b/irker.xml index c67c5e7..5d284b9 100644 --- a/irker.xml +++ b/irker.xml @@ -17,8 +17,7 @@ - irker - -t + irker.py -p number -n namesuffix -d debuglevel @@ -69,11 +68,6 @@ nick collisions by instances running on different sites. daemon will listen. --t -Accept TCP connections. The default is UDP. This choice -trades slightly increased latency for reliability of delivery. - - -d Takes a following value, seting the debugging level from it. This option will generally only be of interest to developers; @@ -96,11 +90,10 @@ for updates and other resources. The implementation uses the Python IRC library -LIMITATIONS -We accept requests via UDP, optimizing for lowest latency and -network load by avoiding TCP connection setup time; the cost is that -delivery is not reliable in the face of packet loss. But see the -description of the option above. +LIMITATIONS +Requests via UDP optimizes for lowest latency and network load +by avoiding TCP connection setup time; the cost is that delivery is +not reliable in the face of packet loss. No attempt at a content-based spam-filtering facility has been made, since IRC servers have to do that anyway. An -- 2.26.2