def generate(self): data = util.generateBytes(HANDSHAKE_LENGTH - CHALLENGE_DIGEST_LENGTH) if self.requestDigest and self.challengeKey: #Here be the evil: hash1 = getDigest(self.challengeKey, self.requestDigest) hash2 = getDigest(hash1, data) data += hash2 else: data += util.generateBytes(CHALLENGE_DIGEST_LENGTH) return data
def buildClient(self, protocol, params, *args): """ Create an instance of a subclass of L{Client}. Override this method to alter how L{Client} instances are created. @param protocol: The L{rtmp.ServerProtocol} instance. @param params: The connection parameters sent from the client, this includes items such as the connection url, and user agent @type params: C{dict} @param args: The client supplied arguments to NetConnection.connect() """ c = self.client(protocol) c.id = util.generateBytes(9, readable=True) # Inject properties into the client object # TODO: Evaluate if these should be defined with @property in the # Client class itself. c.application = self try: c.ip = c.nc.transport.getPeer().host except AttributeError: c.ip = None tcUrl = params.get('tcUrl', '') c.protocol = urlparse.urlparse(tcUrl)[0] if c.protocol == '': c.protocol = None c.pageUrl = params.get('pageUrl', None) c.uri = params.get('tcUrl', None) c.agent = params.get('flashVer', None) return c
def generate(self): """ """ d = self.buffer = BufferedByteStream() d.write_ulong(self.uptime) d.write_ulong(self.version) d.write(util.generateBytes(HANDSHAKE_LENGTH - 8)) self._generateChallenge() return d.getvalue()
def _generate_payload(): return util.generateBytes(handshake.HANDSHAKE_LENGTH - 8)