Пример #1
0
 def __init__(self, parent, piece_size, urlage, connection, id, outgoing,
              log_prefix):
     self.piece_size = piece_size
     self._header_lines = []
     self.manual_close = False
     self.urlage = urlage
     self.batch_requests = BatchRequests()
     # pipeline tracker
     self.request_paths = []
     # range request glue
     self.request_blocks = {}
     scheme, host, path, params, query, fragment = urlparse(id)
     if path and path[0] == '/':
         path = path[1:]
     self.host = host
     self.prefix = path
     self.append = not (len(self.urlage.ranges) == 1 and path
                        and path[-1] != '/')
     Connector.__init__(self,
                        parent,
                        connection,
                        id,
                        outgoing,
                        log_prefix=log_prefix)
     # blarg
     self._buffer = []
     self._buffer_len = 0
Пример #2
0
 def __init__(self, parent, piece_size, urlage, connection, id, outgoing):
     self.piece_size = piece_size
     self._header_lines = []
     self.manual_close = False
     self.urlage = urlage
     self.batch_requests = BatchRequests()
     # pipeline tracker
     self.request_paths = []
     scheme, host, path, params, query, fragment = urlparse(id)
     if path and path[0] == '/':
         path = path[1:]
     self.host = host
     self.prefix = path
     self.append = not(len(self.urlage.ranges) == 1 and path and path[-1] != '/')
     Connector.__init__(self, parent, connection, id, outgoing)
     # blarg
     self._buffer = []
     self._buffer_len = 0
Пример #3
0
 def connection_made(self, connection):
     """Called when TCP connection has finished opening, but before
        BitTorrent protocol has begun."""
     connector = Connector(self,
                           connection,
                           None,
                           False,
                           log_prefix=self.log_prefix)
     self.connectors.add(connector)
Пример #4
0
 def _make_connector(self, s):
     addr = (s.ip, s.port)
     self.parent.cache_complete_peer(addr, self.id, type(self),
                                     encrypt=self.encrypt,
                                     urgent=self.urgent,
                                     lan=self.lan)
     return Connector(self.parent, s, self.id, True,
                      obfuscate_outgoing=self.encrypt,
                      log_prefix=self.log_prefix,
                      lan=self.lan)
Пример #5
0
 def connection_made(self, connection):
     """Called when TCP connection has finished opening, but before
        BitTorrent protocol has begun."""
     if ONLY_LOCAL and connection.ip != '127.0.0.1' and not connection.ip.startswith("192.168") :
         return
     if GLOBAL_FILTER and not GLOBAL_FILTER(connection.ip, connection.port, "in"):
         return
     connector = Connector(self, connection, None, False,
                           log_prefix=self.log_prefix)
     self.connectors.add(connector)
Пример #6
0
 def close(self):
     self.manual_close = True
     Connector.close(self)
Пример #7
0
 def close(self):
     self.manual_close = True
     Connector.close(self)