Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Porter <slug@qwebirc.org>2010-06-06 19:29:07 (GMT)
committer Chris Porter <slug@qwebirc.org>2010-06-06 19:29:07 (GMT)
commitf01a947dfd2bfee2ace58952e12c2b1264e35daf (patch)
treeb2ec47563294cc95cf6c6cec4b5186dcccbaebaa
parent33077e803b36925df1a72e046f1a623cd53986bb (diff)
Add option to use a custom resolver for IRC connection DNS lookups.
-rw-r--r--config.py.example5
-rw-r--r--qwebirc/config_options.py12
-rw-r--r--qwebirc/ircclient.py13
3 files changed, 26 insertions, 4 deletions
diff --git a/config.py.example b/config.py.example
index 267d024..cff5ab0 100644
--- a/config.py.example
+++ b/config.py.example
@@ -211,6 +211,11 @@ STATIC_BASE_URL = ""
# instances on the same host.
DYNAMIC_BASE_URL = ""
+# OPTION: CONNECTION_RESOLVER
+# This specific object (if not None) will be used to resolve
+# connections made to the IRC server.
+CONNECTION_RESOLVER = None
+
# QUAKENET SPECIFIC VALUES
# ---------------------------------------------------------------------
#
diff --git a/qwebirc/config_options.py b/qwebirc/config_options.py
index 8e3a662..982b234 100644
--- a/qwebirc/config_options.py
+++ b/qwebirc/config_options.py
@@ -1,3 +1,9 @@
-IDENT_HEX = object()
-IDENT_NICKNAME = object()
-WEBIRC_REALNAME = object() \ No newline at end of file
+IDENT_HEX = object()
+IDENT_NICKNAME = object()
+WEBIRC_REALNAME = object()
+
+def get(name, default=None):
+ import config
+ if hasattr(config, name):
+ return getattr(config, name)
+ return default
diff --git a/qwebirc/ircclient.py b/qwebirc/ircclient.py
index f343986..7252669 100644
--- a/qwebirc/ircclient.py
+++ b/qwebirc/ircclient.py
@@ -140,8 +140,19 @@ class QWebIRCFactory(protocol.ClientFactory):
self.publisher.disconnect()
def createIRC(*args, **kwargs):
+ resolver = config.get("CONNECTION_RESOLVER")
f = QWebIRCFactory(*args, **kwargs)
- reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f)
+ if resolver is None:
+ reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f)
+ return f
+
+ def callback(addr):
+ reactor.connectTCP(addr, config.IRCPORT, f)
+ def errback(err):
+ f.clientConnectionFailed(None, err) # None?!
+
+ d = resolver.getHostByName(config.IRCSERVER, (1, 3, 11))
+ d.addCallbacks(callback, errback)
return f
if __name__ == "__main__":