def RemoveMapping(self, src): try: portforward.del_mapping(protocol_string_to_enum(src)) logger.debug("Done") return True except KeyError: logger.debug("Fail") return False
msgtype, params = socketproto.read_message(client) if msgtype == socketproto.Messages.AddProxy: src, dest = params try: portforward.add_mapping(src, dest) socketproto.write_message(client, True) logger.debug("Done") except socket.error as e: socketproto.write_message(client, False) logger.debug("Fail\n\t-%s", e) elif msgtype == socketproto.Messages.DelProxy: src = params try: portforward.del_mapping(src) socketproto.write_message(client, True) logger.debug("Done") except KeyError: socketproto.write_message(client, False) logger.debug("Fail") elif msgtype == socketproto.Messages.GetProxies: src_to_dest = [] for svr in portforward.src_to_svr.values(): src = svr._src dest = svr._dest src_to_dest.append((src, dest)) socketproto.write_message(client, (socketproto.Messages.GetProxies, src_to_dest))
msgtype, params = socketproto.read_message(client) if msgtype == socketproto.Messages.AddProxy: src, dest = params try: portforward.add_mapping(src, dest) socketproto.write_message(client, True) logger.debug("Done") except socket.error as e: socketproto.write_message(client, False) logger.debug("Fail\n\t-%s", e) elif msgtype == socketproto.Messages.DelProxy: src = params try: portforward.del_mapping(src) socketproto.write_message(client, True) logger.debug("Done") except KeyError: socketproto.write_message(client, False) logger.debug("Fail") elif msgtype == socketproto.Messages.GetProxies: src_to_dest = [] for svr in portforward.src_to_svr.values(): src = svr._src dest = svr._dest src_to_dest.append((src, dest)) socketproto.write_message( client, (socketproto.Messages.GetProxies, src_to_dest))