Package twisted :: Package protocols :: Module gnutella :: Class GnutellaRouter |
[show private | hide private]
[frames | no frames]

## Class GnutellaRouter

    BaseProtocol --+
                   |
            Protocol --+
                       |
            LineReceiver --+
                           |
              GnutellaTalker --+
                               |
                              GnutellaRouter

This is a well-behaved Gnutella servent that routes messages as it should. It does not, however, serve any actual files. If you want to run a Gnutella servent that serves files, try the GnutellaServent class. If you want to use GnutellaRouter for something, subclass it and override the methods named {ping,pong,push,query,queryHit}Received(). But please remember that you have to call GnutellaRouter's `pingReceived()' from your overridden `pingReceived()' if you want it to route the ping!

Method Summary
| `__init__(self)`
| ``connectionFailed`(self)` (Deprecated) (inherited from `Protocol`)
| ``connectionLost`(self, reason)` Called when the connection is shut down. (inherited from `Protocol`)
| ``connectionMade`(self)` Called when a connection is made. (inherited from `GnutellaTalker`)
| ``dataReceived`(self, data)` Protocol.dataReceived. (inherited from `LineReceiver`)
| ``descriptorReceived`(self, descriptor)` A Gnutella descriptor has arrived. (inherited from `GnutellaTalker`)
| ``handlePing`(self, descriptorId, ttl, hops, payload)` A ping message has arrived. (inherited from `GnutellaTalker`)
| `handlePong(self, descriptorId, ttl, hops, payload)` (inherited from `GnutellaTalker`)
| `handlePush(self, descriptorId, ttl, hops, payload)` (inherited from `GnutellaTalker`)
| `handleQuery(self, descriptorId, ttl, hops, payload)` (inherited from `GnutellaTalker`)
| `handleQueryHit(self, descriptorId, ttl, hops, payload)` (inherited from `GnutellaTalker`)
| ``lineLengthExceeded`(self, line)` Called when the maximum line length has been reached. (inherited from `LineReceiver`)
| ``lineReceived`(self, line)` Precondition: We must be expecting a GNUTELLA CONNECT handshake move.: (self.initiator and (self.handshake == "initiatorsaidhello")) or ((not self.initiator) and (self.handshake == "start")): "self.initiator: %s, self.handshake: %s, line: %s" % (str(self.initiator), str(self.handshake), str(line),) (inherited from `GnutellaTalker`)
| ``pingReceived`(self, descriptorId, ttl, hops)` Override this to handle ping messages. (inherited from `GnutellaTalker`)
| ``pongReceived`(self, descriptorId, ttl, hops, ipAddress, port, numberOfFilesShared, kbShared)` Override this to handle pong messages. (inherited from `GnutellaTalker`)
| ``pushReceived`(descriptorId, ttl, hops, ipAddress, port, serventIdentifier, fileIndex)` Override this to handle push messages. (inherited from `GnutellaTalker`)
| ``queryHitReceived`(self, descriptorId, ttl, hops, ipAddress, port, resultSet, serventIdentifier, speed)` Override this to handle query hit messages. (inherited from `GnutellaTalker`)
| ``queryReceived`(self, descriptorId, ttl, hops, searchCriteria, minimumSpeed)` Override this to handle query messages. (inherited from `GnutellaTalker`)
| ``rawDataReceived`(self, data)` Override this for when raw data is received. (inherited from `GnutellaTalker`)
| ``sendDescriptor`(self, descriptorId, payloadDescriptor, ttl, payload)` Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) Precondition: payload must not be larger than MAXUINT32 bytes.: len(payload) <= MAXUINT32: "len(payload): %s" (inherited from `GnutellaTalker`)
| ``sendLine`(self, line)` Sends a line to the other end of the connection. (inherited from `LineReceiver`)
| ``sendPing`(self, ttl)` Precondition: ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) (inherited from `GnutellaTalker`)
| ``sendPong`(self, ttl, descriptorId, host, port, numberOfFilesShared, kbShared)` Precondition: ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) Precondition: host must be a well-formed IPv4 address.: is_ipv4(host): "host: %s" % str(host) Precondition: port must be > 0 and <= MAXUINT16.: (port > 0) and (port <= MAXUINT16): "port: %s" % str(port) Precondition: numberOfFilesShared must be >= 0 and <= MAXUINT32.: (numberOfFilesShared >= 0) and (numberOfFilesShared <= MAXUINT32): "numberOfFilesShared: %s" % str(numberOfFilesShared) Precondition: kbShared must be >- 0 and <= MAXUINT32: (kbShared >= 0) and (kbShared <= MAXUINT32): "kbShared: %s" % str(kbShared) (inherited from `GnutellaTalker`)
| `setInitiator(self)` (inherited from `GnutellaTalker`)
| ``setLineMode`(self, extra)` Sets the line-mode of this receiver. (inherited from `LineReceiver`)
| ``setRawMode`(self)` Sets the raw mode of this receiver. (inherited from `LineReceiver`)

Generated by Epydoc 1.1 on Thu May 8 13:16:37 2003 | http://epydoc.sf.net