added default transport node
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.
This commit is contained in:
parent
14aafad337
commit
d4d869312e
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"
|
APP_NAME = "tinyweb"
|
||||||
ASPECTS = ["server"]
|
ASPECTS = ["server"]
|
||||||
IDENTITY_FILE = "tinyweb_identity"
|
IDENTITY_FILE = "tinyweb_identity"
|
||||||
|
DEFAULT_TRANSPORT_HOST = "reticulum.derickphan.com"
|
||||||
|
DEFAULT_TRANSPORT_PORT = 4242
|
||||||
|
|
||||||
|
|
||||||
def load_or_create_identity():
|
def load_or_create_identity():
|
||||||
|
|
@ -40,9 +42,41 @@ def start_gateway(reticulum):
|
||||||
thread.start()
|
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():
|
def main():
|
||||||
init_db()
|
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()
|
identity = load_or_create_identity()
|
||||||
|
|
||||||
destination = RNS.Destination(
|
destination = RNS.Destination(
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,13 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
[[Default Interface]]
|
[[Default Interface]]
|
||||||
type = AutoInterface
|
type = AutoInterface
|
||||||
enabled = Yes
|
enabled = Yes
|
||||||
EOF
|
|
||||||
|
|
||||||
if [ -n "$RNS_TCP_HOST" ]; then
|
[[TCP Transport]]
|
||||||
RNS_TCP_PORT="${RNS_TCP_PORT:-4242}"
|
|
||||||
cat >> "$CONFIG_FILE" <<EOF
|
|
||||||
|
|
||||||
[[TCP Link]]
|
|
||||||
type = TCPClientInterface
|
type = TCPClientInterface
|
||||||
enabled = yes
|
enabled = yes
|
||||||
target_host = $RNS_TCP_HOST
|
target_host = ${RNS_TCP_HOST:-reticulum.derickphan.com}
|
||||||
target_port = $RNS_TCP_PORT
|
target_port = ${RNS_TCP_PORT:-4242}
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export RNS_CONFIG_DIR="$CONFIG_DIR"
|
export RNS_CONFIG_DIR="$CONFIG_DIR"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue