Ticket #5208: socksv4-fix.patch

File socksv4-fix.patch, 1.5 KB (added by lebek, 5 years ago)
  • twisted/protocols/socks.py

     
    162162            self.otherConn.transport.loseConnection()
    163163
    164164    def authorize(self,code,server,port,user):
    165         log.msg("code %s connection to %s:%s (user %s) authorized" % (code,server,port,user))
     165        log.msg("code %s connection to %s:%s (user %s) authorized" % (
     166            code, server, port, user))
    166167        return 1
    167168
    168169    def connectClass(self, host, port, klass, *args):
    169         return protocol.ClientCreator(reactor, klass, *args).connectTCP(host,port)
     170        client = protocol.ClientCreator(self.reactor, klass, *args)
     171        return client.connectTCP(host, port)
    170172
    171173    def listenClass(self, port, klass, *args):
    172         serv = reactor.listenTCP(port, klass(*args))
    173         return defer.succeed(serv.getHost()[1:])
     174        serv = self.reactor.listenTCP(port, klass(*args))
     175        address = serv.getHost()
     176        return defer.succeed((address.host, address.port))
    174177
    175     def makeReply(self,reply,version=0,port=0,ip="0.0.0.0"):
    176         self.transport.write(struct.pack("!BBH",version,reply,port)+socket.inet_aton(ip))
     178    def makeReply(self, reply, version=0, port=0, ip="0.0.0.0"):
     179        frame = struct.pack("!BBH", version, reply, port) + socket.inet_aton(ip)
     180        self.transport.write(frame)
    177181        if reply!=90: self.transport.loseConnection()
    178182
    179183    def write(self,data):