我从https://github.com/MahjongRepository/tenhou-python-bot开始运行麻将机器人下载到http://tenhou.net。代码显示它使用TCP套接字连接到服务器,而WireShark表示发送/接收了UDP数据包。此外,代码表明消息是纯文本,可以被视为ascii字符串,而WireShark说它无法识别有效负载。
这里发生了什么?有代理吗?有加密隧道吗?如何只通过窃听的数据包捕获INIT消息?非常感谢你!
client.py中的代码:
def connect(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((settings.TENHOU_HOST, 10080))
def _read_message(self):
message = self.socket.recv(2048)
return message.decode('utf-8')
def _send_message(self, message):
# tenhou requires an empty byte in the end of each sending message
message += '\0'
self.socket.sendall(message.encode())
def authenticate(self):
self._send_message('<HELO name="{}" tid="f0" sx="M" />'.format(quote(settings.USER_ID)))
messages = self._get_multiple_messages()
auth_message = messages[0]
# Several blocks ommitted
WireShark PrintScreen