From: Chris Porter Date: Sat, 19 Feb 2011 04:42:38 +0000 (+0000) Subject: Merge soczol's patch from https://bitbucket.org/soczol/qwebirc/changeset/450739e6defd X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/dc8d270f3ea63681189ade6e87e2f7bef18f5f81 Merge soczol's patch from https://bitbucket.org/soczol/qwebirc/changeset/450739e6defd (with a few changes). --- diff --git a/config.py.example b/config.py.example index 7bdda5d..485b0f3 100644 --- a/config.py.example +++ b/config.py.example @@ -34,6 +34,14 @@ REALNAME = "http://moo.com/" # supplied nickname as their ident. IDENT = "webchat" +# OPTION: OUTGOING_IP +# The IP address to bind to when connecting to the IRC server. +# +# This will not change the IP address that qwebirc listens on. +# You will need to call run.py with the --ip/-i option if you +# want that. +#OUTGOING_IP = "127.0.0.1" + # OPTION: WEBIRC_MODE # This option controls how the IP/hostname of the connecting # browser will be sent to IRC. diff --git a/qwebirc/ircclient.py b/qwebirc/ircclient.py index efda3d4..f517430 100644 --- a/qwebirc/ircclient.py +++ b/qwebirc/ircclient.py @@ -146,13 +146,18 @@ class QWebIRCFactory(protocol.ClientFactory): def createIRC(*args, **kwargs): f = QWebIRCFactory(*args, **kwargs) + + tcpkwargs = {} + if hasattr(config, "OUTGOING_IP"): + tcpkwargs["bindAddress"] = (config.OUTGOING_IP, 0) + if CONNECTION_RESOLVER is None: - reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f) + reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs) return f def callback(result): name, port = random.choice(sorted((str(x.payload.target), x.payload.port) for x in result[0])) - reactor.connectTCP(name, port, f) + reactor.connectTCP(name, port, f, **tcpkwargs) def errback(err): f.clientConnectionFailed(None, err) # None?!