def loadFromPacket(packet): obj = Query() proto = Proto(packet, 3) obj.sequenceId = proto.get_fixed_int(1) proto.get_filler(1) obj.query = proto.get_eop_str() return obj
def loadFromPacket(packet): obj = ERR() proto = Proto(packet, 3) obj.sequenceId = proto.get_fixed_int(1) proto.get_filler(1) obj.errorCode = proto.get_fixed_int(2) proto.get_filler(1) obj.sqlState = proto.get_fixed_str(5) obj.errorMessage = proto.get_eop_str() return obj
def loadFromPacket(packet): obj = Response() proto = Proto(packet, 3) obj.sequenceId = proto.get_fixed_int(1) obj.capabilityFlags = proto.get_fixed_int(2) proto.offset -= 2 if obj.hasCapabilityFlag(Flags.CLIENT_PROTOCOL_41): obj.capabilityFlags = proto.get_fixed_int(4) obj.maxPacketSize = proto.get_fixed_int(4) obj.characterSet = proto.get_fixed_int(1) proto.get_filler(23) obj.username = proto.get_null_str() if obj.hasCapabilityFlag( Flags.CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA): authResponseLen = proto.get_lenenc_int() obj.authResponse = proto.get_fixed_str(authResponseLen) elif obj.hasCapabilityFlag(Flags.CLIENT_SECURE_CONNECTION): authResponseLen = proto.get_lenenc_int() obj.authResponse = proto.get_fixed_str(authResponseLen) else: obj.authResponse = proto.get_null_str() if obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_WITH_DB): obj.schema = proto.get_null_str() if obj.hasCapabilityFlag(Flags.CLIENT_PLUGIN_AUTH): obj.pluginName = proto.get_null_str() if obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_ATTRS): attribute_length = proto.get_lenenc_int() while proto.has_remaining_data(): k = proto.get_lenenc_str() v = proto.get_lenenc_str() obj.clientAttributes[k] = v else: obj.capabilityFlags = proto.get_fixed_int(2) obj.maxPacketSize = proto.get_fixed_int(3) obj.username = proto.get_null_str() if obj.hasCapabilityFlag(Flags.CLIENT_CONNECT_WITH_DB): obj.authResponse = proto.get_null_str() obj.schema = proto.get_null_str() else: obj.authResponse = proto.get_eop_str() return obj