Skip to content

mod_node

Germán Luis Aracil Boned edited this page Apr 6, 2026 · 1 revision

mod_node

Category: Infrastructure | Version: v0.4.0 | Source: modules/mod_node/mod_node.c

Description

Node federation over TCP/TLS. Connects Portal instances into a distributed network. Remote paths transparently accessible as /node_name/path. Worker thread pool per peer. PORTAL02 wire protocol. Hub routing for NAT traversal.

Paths

Path Method Description
/node/peers GET List all known peers and connection status
/node/connect ACTION Connect to a peer
/node/disconnect ACTION Disconnect from a peer
/node/status GET Federation status overview
/node/<peer>/<path> * Route message to remote peer

Wire Protocol — PORTAL02

┌────────┬────────┬──────────┬��──────────┬──────────────┐
│ MAGIC  │ VERSION│ MSG_TYPE │ BODY_LEN  │    BODY      │
│ 4 bytes│ 2 bytes│ 1 byte   ��� 4 bytes   │ variable     │
│"PRT\0" │ 0x0002 │          │ uint32 BE │ serialized   │
└────────┴────────┴──────────┴───────────┴──────���───────┘

Authentication

SHA-256 challenge-response:

  1. Server sends 32-byte random nonce
  2. Client computes SHA-256(nonce + federation_key)
  3. Server verifies the hash
  4. Both sides authenticated (mutual)

Configuration

[mod_node]
name = portal-central
federation_key = shared_secret_here
listen_port = 9090
tls = true
tls_cert = /etc/portal/cert.pem
tls_key = /etc/portal/key.pem

[peer:office]
host = 192.168.1.100
port = 9090
auto_connect = true

[peer:cloud]
host = cloud.example.com
port = 9090
auto_connect = true
hub = true     # route through this peer for NAT traversal

Features

  • Transparent routing: /node/office/health → health on office peer
  • Auto-reconnect: Exponential backoff on disconnection
  • Worker pools: Dedicated thread pool per peer connection
  • Hub routing: NAT traversal via designated hub nodes
  • TLS encryption: Optional TLS on federation links

Clone this wiki locally