]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - qwebirc/ircclient.py
Merge.
[irc/quakenet/qwebirc.git] / qwebirc / ircclient.py
index efda3d4c2a9a37082da1159318bd73884eb15155..8e06eaed64799658e78cf3fa9c5b9612e95db2ee 100644 (file)
@@ -146,13 +146,22 @@ 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)
+    if hasattr(config, "SSLPORT"):
+      from twisted.internet import ssl
+      reactor.connectSSL(config.IRCSERVER, config.SSLPORT, f, ssl.ClientContextFactory(), **tcpkwargs)
+    else:
+      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?!