+
+ tcpkwargs = {}
+ if hasattr(config, "OUTGOING_IP"):
+ tcpkwargs["bindAddress"] = (config.OUTGOING_IP, 0)
+
+ if CONNECTION_RESOLVER is None:
+ 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, **tcpkwargs)
+ def errback(err):
+ f.clientConnectionFailed(None, err) # None?!
+
+ d = CONNECTION_RESOLVER.lookupService(config.IRCSERVER, (1, 3, 11))
+ d.addCallbacks(callback, errback)