def from_bytes(cls, data): if not check_bytes_length(data, 5): return None offset = 1 offset, piece_index = Network.read_integer(data, offset) return cls(piece_index)
def for_receive(cls, data): if not check_bytes_length(data, 16): return None offset = 0 offset, action = read_integer(data, offset) offset, transaction_id = read_integer(data, offset) offset, connection_id = read_long(data, offset) return cls(connection_id, transaction_id, action)
def from_bytes(cls, data): if not check_bytes_length(data, 68): return None offset = 0 offset, length = Network.read_byte_as_int(data, offset) offset, protocol = Network.read_bytes(data, 19, offset) offset, reserved = Network.read_bytes(data, 8, offset) offset, info_hash = Network.read_bytes(data, 20, offset) offset, peer_id = Network.read_bytes(data, 20, offset) result = cls(info_hash) result.length = length result.protocol = protocol result.reserved = reserved result.peer_id = peer_id return result
def from_bytes(cls, data): if not check_bytes_length(data, 1): return None return cls()
def from_bytes(cls, data): if not check_bytes_length(data, 3): return None offset, port = Network.read_ushort(data, 1) return cls(port)