workaround

This commit is contained in:
Luke Rogers 2013-11-29 18:16:17 +13:00
parent 0bb1574ebd
commit 44c7bceaf4
1 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,6 @@ import socket
import struct
import json
try:
import DNS
# Please remember to install the dependancy 'pydns'
@ -11,6 +10,7 @@ try:
except ImportError:
pydns_installed = False
mccolors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74",
u"\x0306,\xa75", u"\x0307,\xa76", u"\x0308,\xa7e", u"\x0309,\xa7a", u"\x0310,\xa73", u"\x0311,\xa7b",
u"\x0312,\xa71", u"\x0313,\xa7d", u"\x0314,\xa78", u"\x0315,\xa77", u"\x02,\xa7l", u"\x0310,\xa79",
@ -58,7 +58,9 @@ def mcping_modern(host, port):
unpack_varint(s) # Packet length
unpack_varint(s) # Packet ID
l = unpack_varint(s) # String length
print l
if not l > 1:
raise Exception
d = ""
while len(d) < l:
@ -167,9 +169,10 @@ def mcping(inp):
host, port = parse_input(inp)
except Exception as e:
return e.args[0]
try:
return mcping_modern(host, port)
except socket.error:
except:
try:
return mcping_legacy(host, port)
except: