mirror of
https://github.com/meshtastic/python.git
synced 2026-05-25 00:35:21 -04:00
better debug output
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
# sudo bin/run.sh --port /dev/ttyUSB0 --setch-shortfast
|
# sudo bin/run.sh --port /dev/ttyUSB0 --setch-shortfast
|
||||||
# sudo bin/run.sh --port /dev/ttyUSB0 --tunnel --debug
|
# sudo bin/run.sh --port /dev/ttyUSB0 --tunnel --debug
|
||||||
# ssh -Y root@192.168.10.151 (or dietpi), default password p
|
# ssh -Y root@192.168.10.151 (or dietpi), default password p
|
||||||
|
# ncat -e /bin/cat -k -u -l 1235
|
||||||
|
# ncat -u 10.115.64.152 1235
|
||||||
|
|
||||||
# FIXME - we aren't seeing ping replys from the remote node - check device logs
|
# FIXME - we aren't seeing ping replys from the remote node - check device logs
|
||||||
# FIXME: use a more optimal MTU
|
# FIXME: use a more optimal MTU
|
||||||
@@ -100,16 +102,14 @@ class Tunnel:
|
|||||||
if packet["from"] == self.iface.myInfo.my_node_num:
|
if packet["from"] == self.iface.myInfo.my_node_num:
|
||||||
logging.debug("Ignoring message we sent")
|
logging.debug("Ignoring message we sent")
|
||||||
else:
|
else:
|
||||||
logging.debug(f"Received mesh tunnel message type={type(p)} len={len(p)}, forwarding to IP")
|
logging.debug(f"Received mesh tunnel message type={type(p)} len={len(p)}")
|
||||||
|
# we don't really need to check for filtering here (sender should have checked), but this provides
|
||||||
|
# useful debug printing on types of packets received
|
||||||
|
if not self._shouldFilterPacket(p):
|
||||||
self.tun.write(p)
|
self.tun.write(p)
|
||||||
|
|
||||||
def __tunReader(self):
|
def _shouldFilterPacket(self, p):
|
||||||
tap = self.tun
|
"""Given a packet, decode it and return true if it should be ignored"""
|
||||||
logging.debug("TUN reader running")
|
|
||||||
while True:
|
|
||||||
p = tap.read()
|
|
||||||
#logging.debug(f"IP packet received on TUN interface, type={type(p)}")
|
|
||||||
|
|
||||||
protocol = p[8 + 1]
|
protocol = p[8 + 1]
|
||||||
srcaddr = p[12:16]
|
srcaddr = p[12:16]
|
||||||
destAddr = p[16:20]
|
destAddr = p[16:20]
|
||||||
@@ -133,7 +133,7 @@ class Tunnel:
|
|||||||
ignore = True
|
ignore = True
|
||||||
logging.log(LOG_TRACE, f"ignoring blacklisted UDP port {destport}")
|
logging.log(LOG_TRACE, f"ignoring blacklisted UDP port {destport}")
|
||||||
else:
|
else:
|
||||||
logging.debug(f"udp srcport={srcport}, destport={destport}")
|
logging.debug(f"forwarding udp srcport={srcport}, destport={destport}")
|
||||||
elif protocol == 0x06: # TCP
|
elif protocol == 0x06: # TCP
|
||||||
srcport = readnet_u16(p, subheader)
|
srcport = readnet_u16(p, subheader)
|
||||||
destport = readnet_u16(p, subheader + 2)
|
destport = readnet_u16(p, subheader + 2)
|
||||||
@@ -141,11 +141,21 @@ class Tunnel:
|
|||||||
ignore = True
|
ignore = True
|
||||||
logging.log(LOG_TRACE, f"ignoring blacklisted TCP port {destport}")
|
logging.log(LOG_TRACE, f"ignoring blacklisted TCP port {destport}")
|
||||||
else:
|
else:
|
||||||
logging.debug(f"tcp srcport={srcport}, destport={destport}")
|
logging.debug(f"forwarding tcp srcport={srcport}, destport={destport}")
|
||||||
else:
|
else:
|
||||||
logging.warning(f"unexpected protocol 0x{protocol:02x}, src={ipstr(srcaddr)}, dest={ipstr(destAddr)}")
|
logging.warning(f"forwarding unexpected protocol 0x{protocol:02x}, src={ipstr(srcaddr)}, dest={ipstr(destAddr)}")
|
||||||
|
|
||||||
if not ignore:
|
return ignore
|
||||||
|
|
||||||
|
def __tunReader(self):
|
||||||
|
tap = self.tun
|
||||||
|
logging.debug("TUN reader running")
|
||||||
|
while True:
|
||||||
|
p = tap.read()
|
||||||
|
#logging.debug(f"IP packet received on TUN interface, type={type(p)}")
|
||||||
|
destAddr = p[16:20]
|
||||||
|
|
||||||
|
if not self._shouldFilterPacket(p):
|
||||||
self.sendPacket(destAddr, p)
|
self.sendPacket(destAddr, p)
|
||||||
|
|
||||||
def _ipToNodeId(self, ipAddr):
|
def _ipToNodeId(self, ipAddr):
|
||||||
|
|||||||
Reference in New Issue
Block a user