def get_server_info(self, gameid, session_id, client_id): """Get server by public IP.""" server = None ip_str = self.session_list[session_id][client_id]['addr'][0] servers = self.server_manager.get_natneg_server(session_id) \ ._getvalue() for console in [False, True]: if server is not None: break ip = str(utils.get_ip_from_str(ip_str, console)) server = next((s for s in servers if s['publicip'] == ip), None) return server
def get_server_info_alt(self, gameid, session_id, client_id): """Get server by local address.""" server = None ip_str = self.session_list[session_id][client_id]['addr'][0] for console in [False, True]: if server is not None: break ip = str(utils.get_ip_from_str(ip_str, console)) server = self.server_manager.find_server_by_local_address( ip, self.session_list[session_id][client_id]['localaddr'], self.session_list[session_id][client_id] ['gameid'])._getvalue() return server
def get_server_info_alt(self, gameid, session_id, client_id): """Get server by local address.""" server = None ip_str = self.session_list[session_id][client_id]['addr'][0] for console in [False, True]: if server is not None: break ip = str(utils.get_ip_from_str(ip_str, console)) server = self.server_manager.find_server_by_local_address( ip, self.session_list[session_id][client_id]['localaddr'], self.session_list[session_id][client_id]['gameid'] )._getvalue() return server