Add default internet transport node for zero-config mesh connectivity
New TinyWeb instances now auto-connect to reticulum.derickphan.com:4242 so users get internet mesh connectivity out of the box without any manual Reticulum configuration. Env var overrides still supported. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b49b1df8b5
commit
2adef21ec6
2 changed files with 38 additions and 10 deletions
36
app.py
36
app.py
|
|
@ -11,6 +11,8 @@ from gateway import GatewayState, GatewayHandler, GATEWAY_PORT
|
|||
APP_NAME = "tinyweb"
|
||||
ASPECTS = ["server"]
|
||||
IDENTITY_FILE = "tinyweb_identity"
|
||||
DEFAULT_TRANSPORT_HOST = "reticulum.derickphan.com"
|
||||
DEFAULT_TRANSPORT_PORT = 4242
|
||||
|
||||
|
||||
def load_or_create_identity():
|
||||
|
|
@ -40,9 +42,41 @@ def start_gateway(reticulum):
|
|||
thread.start()
|
||||
|
||||
|
||||
def ensure_rns_config(config_dir):
|
||||
"""Generate a default Reticulum config with internet transport if none exists."""
|
||||
if config_dir is None:
|
||||
config_dir = os.path.expanduser("~/.reticulum")
|
||||
config_file = os.path.join(config_dir, "config")
|
||||
if os.path.exists(config_file):
|
||||
return
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
with open(config_file, "w") as f:
|
||||
f.write(f"""[reticulum]
|
||||
enable_transport = False
|
||||
share_instance = Yes
|
||||
|
||||
[logging]
|
||||
loglevel = 4
|
||||
|
||||
[interfaces]
|
||||
[[Default Interface]]
|
||||
type = AutoInterface
|
||||
enabled = Yes
|
||||
|
||||
[[TCP Transport]]
|
||||
type = TCPClientInterface
|
||||
enabled = yes
|
||||
target_host = {DEFAULT_TRANSPORT_HOST}
|
||||
target_port = {DEFAULT_TRANSPORT_PORT}
|
||||
""")
|
||||
print(f"Created Reticulum config at {config_file}")
|
||||
|
||||
|
||||
def main():
|
||||
init_db()
|
||||
reticulum = RNS.Reticulum(configdir=os.environ.get("RNS_CONFIG_DIR"))
|
||||
config_dir = os.environ.get("RNS_CONFIG_DIR")
|
||||
ensure_rns_config(config_dir)
|
||||
reticulum = RNS.Reticulum(configdir=config_dir)
|
||||
identity = load_or_create_identity()
|
||||
|
||||
destination = RNS.Destination(
|
||||
|
|
|
|||
|
|
@ -20,19 +20,13 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
|||
[[Default Interface]]
|
||||
type = AutoInterface
|
||||
enabled = Yes
|
||||
EOF
|
||||
|
||||
if [ -n "$RNS_TCP_HOST" ]; then
|
||||
RNS_TCP_PORT="${RNS_TCP_PORT:-4242}"
|
||||
cat >> "$CONFIG_FILE" <<EOF
|
||||
|
||||
[[TCP Link]]
|
||||
[[TCP Transport]]
|
||||
type = TCPClientInterface
|
||||
enabled = yes
|
||||
target_host = $RNS_TCP_HOST
|
||||
target_port = $RNS_TCP_PORT
|
||||
target_host = ${RNS_TCP_HOST:-reticulum.derickphan.com}
|
||||
target_port = ${RNS_TCP_PORT:-4242}
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
export RNS_CONFIG_DIR="$CONFIG_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue