def dataReceived(self, data): if self._firstByte: if data[0] != '\x00': # we don't support the HTTP relay self.transport.loseConnection() return data = data[1:] self._firstByte = False BaseProtocol.dataReceived(self, data)
def connectionMade(self): """ When a connection is made, a timeout timer is started, and if the user does not request connection acceptance within reasonable time, disconnect (to prevent flood attacks). """ BaseProtocol.connectionMade(self) timeOut = self.factory.timeOut if timeOut is not None: self._timeoutCall = reactor.callLater(timeOut, self._timedOut)
def connectionMade(self): """ Sends a connection acceptance request to the server after the connection has been made. """ BaseProtocol.connectionMade(self) self._udpCheck = LoopingCall(self._requestUDP) self._channelList = [] self._channelListDefer = [] hello = client.Request() hello.request = CONNECT hello.version = self.revision self.transport.write('\x00') self.sendLoader(hello)
def connectionLost(self, reason): """ Once the connection is lost, put back the client ID into the pool, and remove the client from all the channels it has signed on to. """ BaseProtocol.connectionLost(self, reason) factory = self.factory if self._timeoutCall is not None and self._timeoutCall.active(): self._timeoutCall.cancel() self._timeoutCall = None if self._currentPing is not None and self._currentPing.active(): self._currentPing.cancel() self._currentPing = None for channel in self.channels.values(): self.leaveChannel(channel) if self.isAccepted: factory.userPool.putBack(self.id) del self.factory.connections[self]