Docs and cleanup for run

This commit is contained in:
Agie Ashwood 2024-07-29 14:13:56 +00:00
parent a63401b632
commit f34d4b999c
6 changed files with 165 additions and 34 deletions

View File

@ -4,6 +4,10 @@ Dispatches to Protocols
### *class* Sponge.base.Filter(cache, onodeID, todo, cLog)
#### cache
Messages is temporary storage for unfinished messages
#### *async* protoRoute(completeMessage)
Shorthand reference

View File

@ -9,6 +9,18 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. -->
* [PierMesh service runner](/PierMesh/piermesh/src/branch/main/docs/run.md)
* [`Node`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node)
* [`Node.toLog`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.toLog)
* [`Node.actions`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.actions)
* [`Node.todo`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.todo)
* [`Node.network`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.network)
* [`Node.catch`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.catch)
* [`Node.cache`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.cache)
* [`Node.nodeInfo`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.nodeInfo)
* [`Node.onodeID`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.onodeID)
* [`Node.oTransmitter`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.oTransmitter)
* [`Node.processed`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.processed)
* [`Node.proc`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.proc)
* [`Node.mTasks`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.mTasks)
* [`Node.action_initNodeDH()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.action_initNodeDH)
* [`Node.action_keyDeriveDH()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.action_keyDeriveDH)
* [`Node.action_map()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.action_map)
@ -17,7 +29,6 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. -->
* [`Node.cLog()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.cLog)
* [`Node.monitor()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.monitor)
* [`Node.spongeListen()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.spongeListen)
* [`Node.toLog`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.toLog)
* [TUI application](/PierMesh/piermesh/src/branch/main/docs/ui.md)
* [`TUI`](/PierMesh/piermesh/src/branch/main/docs/ui.md#ui.TUI)
* [`TUI.visibleLogo`](/PierMesh/piermesh/src/branch/main/docs/ui.md#ui.TUI.visibleLogo)
@ -67,6 +78,7 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. -->
* [`post()`](/PierMesh/piermesh/src/branch/main/docs/Components/hopper.md#Components.hopper.post)
* [`DHEFern`](/PierMesh/piermesh/src/branch/main/docs/Cryptography/DHEFern.md)
* [`Filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md)
* [`Filter.cache`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.base.Filter.cache)
* [`Filter.protoRoute()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.base.Filter.protoRoute)
* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.bubble.filter)
* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.catch.filter)

View File

@ -4,10 +4,98 @@ Main method for running the PierMesh service
### *class* run.Node
Class that handles most of the PierMesh data
Node: Class that handles most of the PierMesh data
[🔗 Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/src/run.py)
#### toLog
We store logs to be processed here
* **Type:**
list
#### actions
Dictionary mapping methods with the action prefix to the method name after action dynamically to be called through Sponge (Sponge.base) filtering
* **Type:**
dict
#### todo
List of actions to execute
* **Type:**
list[dict]
#### network
Network map
* **Type:**
Network
#### catch
Daisy cache for catchs, our domain analog
* **Type:**
Catch
#### cache
Daisy cache for general use
* **Type:**
Cache
#### nodeInfo
Daisy (Components.daisy.Daisy) record containing some information about the node
* **Type:**
[Daisy](/PierMesh/piermesh/src/branch/main/docs/Components/daisy.md#Components.daisy.Daisy)
#### onodeID
PierMesh node ID
* **Type:**
str
#### oTransmitter
LoRa transmitter Transmitter
* **Type:**
[Transmitter](/PierMesh/piermesh/src/branch/main/docs/Transmission/transmission.md#Transmission.transmission.Transmitter)
#### processed
List of IDs of already completed messages so that we dont reprocess messages
* **Type:**
list
#### proc
This process (psutil.Process), used for managing and monitoring PierMesh
* **Type:**
psutil.Process
#### mTasks
Dictionary of PierMesh service tasks
* **Type:**
dict
#### SEE ALSO
`logPassLoop`
: Loop to handle logging to file and TUI
#### *async* action_initNodeDH(data: dict)
Initialize diffie hellman key exchange
@ -78,11 +166,3 @@ Loop to watch for tasks to do
### Notes
We use a common technique here that calls the function from our preloaded actions via dictionary entry
#### toLog
We store logs to be processed here
#### SEE ALSO
`logPassLoop`
: Loop to handle logging to file and TUI

View File

@ -16,6 +16,7 @@ Catch overview
# How to use
Note: these instructions will probably only work on Linux at the moment
Note: check the scripts to make sure they'll work with your system, and in general I reccomend checking scripts before you run them
Follow Meshtastic's guide on setting up your device: [https://meshtastic.org/docs/getting-started/](https://meshtastic.org/docs/getting-started/)

View File

@ -8,30 +8,28 @@ from Transmission.transmission import Transmitter
from Cryptography.DHEFern import DHEFern
from ui import TUI
# Generic imports
import logging
import os
import asyncio
import sys
import time
import psutil
import datetime
import traceback
import threading
import random
from microdot import Request
# Process management library
import psutil
if __name__ == "__main__":
# Global objects for the PierMesh service and the TUI so we can terminate the associated processes later
global nodeOb, tuiOb
"""
Global objects for the PierMesh service and the TUI so we can terminate the associated processes later
"""
tuiOb = None
nodeOb = None
# Enable 500 kB files in the webui
Request.max_content_length = 1024 * 1024 * 0.5
Request.max_body_length = 1024 * 1024 * 0.5
# Pull startup parameters
device, webPort, serverInfoFile, delay, nodeNickname = sys.argv[1:]
@ -48,41 +46,76 @@ if __name__ == "__main__":
class Node:
"""
Class that handles most of the PierMesh data
Node: Class that handles most of the PierMesh data
`🔗 Source <https://git.utopic.work/PierMesh/piermesh/src/branch/main/src/run.py>`_
"""
def __init__(self):
self.toLog = []
"""
Attributes
----------
toLog: list
We store logs to be processed here
actions: dict
Dictionary mapping methods with the action prefix to the method name after action dynamically to be called through Sponge (`Sponge.base`) filtering
todo: list[dict]
List of actions to execute
network: `Network`
Network map
catch: `Catch`
Daisy cache for catchs, our domain analog
cache: `Cache`
Daisy cache for general use
nodeInfo: Daisy
Daisy (`Components.daisy.Daisy`) record containing some information about the node
onodeID: str
PierMesh node ID
oTransmitter: Transmitter
LoRa transmitter `Transmitter`
processed: list
List of IDs of already completed messages so that we don't reprocess messages
proc: psutil.Process
This process (`psutil.Process`), used for managing and monitoring PierMesh
mTasks: dict
Dictionary of PierMesh service tasks
See Also
--------
logPassLoop: Loop to handle logging to file and TUI
"""
def __init__(self):
self.toLog = []
actionsList = [f for f in dir(self) if "action" in f]
self.actions = {}
for a in actionsList:
self.actions[a.split("_")[1]] = getattr(self, a)
self.todo = []
self.cLog(20, "Past action mapping")
self.network = Network()
self.catch = Catch(walk=True)
self.cache = Cache(walk=True)
self.serverInfo = self.cache.get(serverInfoFile)
if self.serverInfo == False:
self.nodeInfo = self.cache.get(serverInfoFile)
if self.nodeInfo == False:
self.cache.create(serverInfoFile, {"nodeID": random.randrange(0, 1000000)})
self.serverInfo = self.cache.get(serverInfoFile)
self.nodeInfo = self.cache.get(serverInfoFile)
self.network.addin(self.serverInfo.get()["nodeID"])
self.cLog(20, "Siph network stack initialized")
self.onodeID = str(self.serverInfo.get()["nodeID"])
self.onodeID = str(self.nodeInfo.get()["nodeID"])
self.server = None
self.todo = []
self.sponge = Filter(self.cache, self.onodeID, self.todo, self.cLog)
self.cLog(20, "Filter initialized")
# self.cLog(30, sys.argv)
self.cLog(10, "Command line arguments: " + ", ".join(sys.argv))
self.oTransmitter = None
self.cLog(20, "Cryptography initializing")
self.cryptographyInfo = DHEFern(self.cache, nodeNickname, self.cLog)

View File

@ -5,8 +5,9 @@ import random, json, time, msgpack
import logging
from microdot import Request
Request.max_content_length = 1024 * 1024 * 8
Request.max_body_length = 1024 * 1024 * 8
# Enable 500 kB files in the webui
Request.max_content_length = 1024 * 1024 * 0.5
Request.max_body_length = 1024 * 1024 * 0.5
Request.max_readline = 1024 * 1024