mirror of
https://github.com/meshtastic/python.git
synced 2025-12-30 03:17:54 -05:00
IP tunnel almost works #35
This commit is contained in:
@@ -19,7 +19,7 @@ args = None
|
||||
|
||||
def onReceive(packet, interface):
|
||||
"""Callback invoked when a packet arrives"""
|
||||
print(f"Received: {packet}")
|
||||
logging.debug(f"Received: {packet}")
|
||||
|
||||
try:
|
||||
# Exit once we receive a reply
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
# using pip3 install pytap2
|
||||
# make sure to "sudo setcap cap_net_admin+eip /usr/bin/python3.8" so python can access tun device without being root
|
||||
# sudo ip tuntap del mode tun tun0
|
||||
# sudo bin/run.sh --port /dev/ttyUSB0 --setch-shortfast
|
||||
# sudo bin/run.sh --port /dev/ttyUSB0 --tunnel --debug
|
||||
|
||||
# FIXME: set MTU correctly
|
||||
# select local ip address based on nodeid
|
||||
# print known node ids as IP addresses
|
||||
# change dev name to mesh
|
||||
# allow setting arbitary IP addresses
|
||||
|
||||
from . import portnums_pb2
|
||||
from pubsub import pub
|
||||
@@ -143,8 +143,10 @@ class Tunnel:
|
||||
return "^all"
|
||||
|
||||
for node in self.iface.nodes.values():
|
||||
if (node["num"] and 0xffff) == ipBits:
|
||||
return node["id"]
|
||||
nodeNum = node["num"] & 0xffff
|
||||
logging.debug(f"Considering nodenum 0x{nodeNum:x} for ipBits 0x{ipBits:x}")
|
||||
if (nodeNum) == ipBits:
|
||||
return node["user"]["id"]
|
||||
return None
|
||||
|
||||
def _nodeNumToIp(self, nodeNum):
|
||||
|
||||
Reference in New Issue
Block a user