diff --git a/app/classes/minecraft/mc_ping.py b/app/classes/minecraft/mc_ping.py index 9995ddd4..2d34dc71 100644 --- a/app/classes/minecraft/mc_ping.py +++ b/app/classes/minecraft/mc_ping.py @@ -72,7 +72,8 @@ class Player: # For the rest of requests see wiki.vg/Protocol -def ping(ip, port=25565): +def ping(ip, port): + print("IN PING PORT: " + str(port)) def read_var_int(): i = 0 j = 0 @@ -88,11 +89,14 @@ def ping(ip, port=25565): if not (k & 0x80): return i - sock = socket.socket() + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: - sock.connect((ip, port)) + print("SOCKET PORT: " + str(port)) + sock.connect((ip, int(port))) + except: pass + print('FALSE 1') return False try: @@ -108,8 +112,10 @@ def ping(ip, port=25565): length = read_var_int() # full packet length if length < 10: if length < 0: + print("LEN < 0 FALSE") return False else: + print("FALSE 2") return False sock.recv(1) # packet type, 0 for pings @@ -118,10 +124,12 @@ def ping(ip, port=25565): while len(data) != length: chunk = sock.recv(length - len(data)) if not chunk: + print("NOT CHUNK FALSE") return False data += chunk logger.debug("Server reports this data on ping: {}".format(data)) + print("Server reports this data on ping: {}".format(data)) return Server(json.loads(data)) finally: sock.close() diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 2d4a4209..4c90aef2 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -165,8 +165,10 @@ class Stats: # TODO: search server properties file for possible override of 127.0.0.1 - internal_ip = server_data.get('server_ip', "127.0.0.1") - server_port = server_settings.get('server_port', "25565") + internal_ip = server_data.get('server-ip', "127.0.0.1") + server_port = server_settings.get('server-port', "25565") + + print("PORT!!!!!: " + str(server_port)) logger.debug("Pinging {} on port {}".format(internal_ip, server_port)) int_mc_ping = ping(internal_ip, int(server_port)) @@ -207,12 +209,18 @@ class Stats: p_stats = self._get_process_stats(server_obj.PID) # TODO: search server properties file for possible override of 127.0.0.1 - internal_ip = server_data.get('server_ip', "127.0.0.1") - server_port = server_settings.get('server_port', "25565") + internal_ip = server_data.get('server-ip', "127.0.0.1") + server_port = server_settings.get('server-port', "25565") + + print(str(server_port)) + + print("Pinging {} on port {}".format(internal_ip, server_port)) logger.debug("Pinging {} on port {}".format(internal_ip, server_port)) int_mc_ping = ping(internal_ip, int(server_port)) + print("PING: " + str(int_mc_ping)) + int_data = False ping_data = {} @@ -238,6 +246,7 @@ class Stats: 'desc': ping_data.get("server_description", False), 'version': ping_data.get("server_version", False) } + print("SERVER STATS LIST LEN(" + str(len(server_stats_list)) + "): ") # add this servers data to the stack server_stats_list.append(server_stats) diff --git a/main.py b/main.py index 7ef4b02f..bc538ba6 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ def do_intro(): console.magenta(intro) -def setup_logging(debug=False): +def setup_logging(debug=True): logging_config_file = os.path.join(os.path.curdir, 'app', 'config',