diff -r bdbcba80e0fa Hellanzb/NZBLeecher/Protocol.py --- a/Hellanzb/NZBLeecher/Protocol.py Wed Nov 14 10:00:29 2007 +0100 +++ b/Hellanzb/NZBLeecher/Protocol.py Thu Nov 22 22:32:04 2007 +0100 @@ -27,18 +27,14 @@ PHI = 1.6180339887498948 # (1 + math.sqr PHI = 1.6180339887498948 # (1 + math.sqrt(5)) / 2 class NZBLeecherFactory(ReconnectingClientFactory): - def __init__(self, username, password, activeTimeout, antiIdleTimeout, hostname, + def __init__(self, username, password, activeTimeout, antiIdleTimeout, serverPoolName, skipGroupCmd, fillServerPriority = 0, color = None): self.username = username self.password = password self.antiIdleTimeout = antiIdleTimeout self.activeTimeout = activeTimeout - self.hostname = hostname self.serverPoolName = serverPoolName self.fillServerPriority = fillServerPriority - - self.host = None - self.port = None # statistics for the current session (sessions end when downloading stops on all # clients). sessionReadBytes and sessionStartime are used to calculate the average @@ -88,6 +84,7 @@ class NZBLeecherFactory(ReconnectingClie p.factory = self p.id = self.clientIds[0] self.clientIds.remove(p.id) + p.host, p.port = addr.host, addr.port # All clients inherit the factory's anti idle timeout setting # FIXME: I don't think there's any reason to copy these values to the @@ -323,7 +320,7 @@ class NZBLeecher(NNTPClient, TimeoutMixi "Override for notification when authInfoFailed() action fails" debug(str(self) + ' AUTHINFO failed: ' + str(err)) # FIXME: This gives us too much scroll. Need to only do it selectively - #error(self.factory.hostname + '[' + str(self.id).zfill(2) + '] Authorization failed: ' + str(err)) + #error(self.host + '[' + str(self.id).zfill(2) + '] Authorization failed: ' + str(err)) self.transport.loseConnection() def connectionMade(self): @@ -428,7 +425,7 @@ class NZBLeecher(NNTPClient, TimeoutMixi login """ if self.username == None and self.password == None: warn('Could not MODE READER on no auth server (%s:%i), returned: %s' % \ - (self.factory.host, self.factory.port, str(err))) + (self.host, self.port, str(err))) reactor.callLater(0, self.fetchNextNZBSegment) elif not self.isLoggedIn: self.setReaderAfterLogin = True diff -r bdbcba80e0fa Hellanzb/NZBLeecher/__init__.py --- a/Hellanzb/NZBLeecher/__init__.py Wed Nov 14 10:00:29 2007 +0100 +++ b/Hellanzb/NZBLeecher/__init__.py Thu Nov 22 22:32:04 2007 +0100 @@ -122,30 +122,28 @@ def connectServer(serverName, serverDict connectionCount = 0 hosts = serverDict['hosts'] connections = int(serverDict['connections']) + antiIdle = int(setWithDefault(serverDict, 'antiIdle', defaultAntiIdle)) + idleTimeout = int(setWithDefault(serverDict, 'idleTimeout', defaultIdleTimeout)) + skipGroupCmd = setWithDefault(serverDict, 'skipGroupCmd', False) + fillServer = setWithDefault(serverDict, 'fillserver', 0) + useSSL = setWithDefault(serverDict, 'ssl', False) + + nsf = NZBLeecherFactory(serverDict['username'], serverDict['password'], + idleTimeout, antiIdle, serverName, skipGroupCmd, + fillServer) + color = nsf.color + Hellanzb.nsfs.append(nsf) + + preWrappedNsf = nsf + nsf = HellaThrottlingFactory(nsf) for host in hosts: - antiIdle = int(setWithDefault(serverDict, 'antiIdle', defaultAntiIdle)) - idleTimeout = int(setWithDefault(serverDict, 'idleTimeout', defaultIdleTimeout)) - skipGroupCmd = setWithDefault(serverDict, 'skipGroupCmd', False) - fillServer = setWithDefault(serverDict, 'fillserver', 0) - useSSL = setWithDefault(serverDict, 'ssl', False) - - nsf = NZBLeecherFactory(serverDict['username'], serverDict['password'], - idleTimeout, antiIdle, host, serverName, skipGroupCmd, - fillServer) - color = nsf.color - Hellanzb.nsfs.append(nsf) - split = host.split(':') host = split[0] if len(split) == 2: port = int(split[1]) else: port = 119 - nsf.host, nsf.port = host, port - - preWrappedNsf = nsf - nsf = HellaThrottlingFactory(nsf) ctxf = None if useSSL: @@ -195,7 +193,8 @@ def connectServer(serverName, serverDict if antiIdle == 0: preWrappedNsf.leecherConnectors.append(connector) connectionCount += 1 - preWrappedNsf.setConnectionCount(connectionCount) + + preWrappedNsf.setConnectionCount(connectionCount) if antiIdle == 0: action = ''