mirror of
https://github.com/meshtastic/python.git
synced 2025-12-29 02:47:53 -05:00
Merge pull request #655 from meshtastic/show-pubkey
Adds admin session_passkey handling for 2.5 remote admin
This commit is contained in:
@@ -199,6 +199,13 @@ def _receiveInfoUpdate(iface, asDict):
|
||||
iface._getOrCreateByNum(asDict["from"])["snr"] = asDict.get("rxSnr")
|
||||
iface._getOrCreateByNum(asDict["from"])["hopLimit"] = asDict.get("hopLimit")
|
||||
|
||||
def _onAdminReceive(iface, asDict):
|
||||
"""Special auto parsing for received messages"""
|
||||
logging.debug(f"in _onAdminReceive() asDict:{asDict}")
|
||||
if "decoded" in asDict:
|
||||
if "admin" in asDict["decoded"] and "from" in asDict:
|
||||
adminMessage: admin_pb2.AdminMessage = asDict["decoded"]["admin"]
|
||||
iface._getOrCreateByNum(asDict["from"])["adminSessionPassKey"] = adminMessage["raw"].session_passkey
|
||||
|
||||
"""Well known message payloads can register decoders for automatic protobuf parsing"""
|
||||
protocols = {
|
||||
@@ -238,4 +245,7 @@ protocols = {
|
||||
portnums_pb2.PortNum.STORE_FORWARD_APP: KnownProtocol("storeforward", storeforward_pb2.StoreAndForward),
|
||||
portnums_pb2.PortNum.NEIGHBORINFO_APP: KnownProtocol("neighborinfo", mesh_pb2.NeighborInfo),
|
||||
portnums_pb2.PortNum.MAP_REPORT_APP: KnownProtocol("mapreport", mqtt_pb2.MapReport),
|
||||
portnums_pb2.PortNum.ADMIN_APP: KnownProtocol(
|
||||
"admin", admin_pb2.AdminMessage, _onAdminReceive
|
||||
),
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class Node:
|
||||
else:
|
||||
self.iface._acknowledgment.receivedAck = True
|
||||
print("")
|
||||
adminMessage = p["decoded"]["admin"]
|
||||
adminMessage: admin_pb2.AdminMessage = p["decoded"]["admin"]
|
||||
if "getConfigResponse" in adminMessage:
|
||||
resp = adminMessage["getConfigResponse"]
|
||||
field = list(resp.keys())[0]
|
||||
@@ -833,7 +833,12 @@ class Node:
|
||||
): # unless a special channel index was used, we want to use the admin index
|
||||
adminIndex = self.iface.localNode._getAdminChannelIndex()
|
||||
logging.debug(f"adminIndex:{adminIndex}")
|
||||
|
||||
if isinstance(self.nodeNum, int):
|
||||
nodeid = self.nodeNum
|
||||
elif self.nodeNum.startswith("!"):
|
||||
nodeid = int(self.nodeNum[1:],16)
|
||||
if ("adminSessionPassKey" in self.iface._getOrCreateByNum(nodeid)):
|
||||
p.session_passkey = self.iface._getOrCreateByNum(nodeid).get("adminSessionPassKey")
|
||||
return self.iface.sendData(
|
||||
p,
|
||||
self.nodeNum,
|
||||
|
||||
Reference in New Issue
Block a user