No description
  • Go 73.4%
  • JavaScript 15%
  • CSS 7.9%
  • HTML 3.5%
  • Makefile 0.2%
Find a file
Pierre-Olivier Mercier 5a3942f351 station/hostapd: Resolve station IPs via udhcpd leases and ARP fallback
The hostapd backend never populated IPs: NewDHCPCorrelator was defined
but never instantiated, and even when it was, the parser only handled
ISC dhcpd's text format. On a BusyBox-based router using udhcpd, every
device showed up with an empty IP.

Two fixes:

- Add a udhcpd binary lease parser. The format is documented in
  busybox/networking/udhcp/dhcpd.{h,c}: an 8-byte big-endian unix-time
  header followed by 36-byte dyn_lease records (expires, IP, MAC,
  20-byte hostname, 2-byte pad). ParseLeases auto-detects the format
  by inspecting the header so the same code path handles both udhcpd
  and ISC text leases.

- Wire the DHCPCorrelator into Backend.Initialize and have it merge
  two sources: ARP first (universal IP fallback for any station that
  has been talked to) and DHCP leases on top (authoritative, carries
  the hostname). ARP fills the gap when leases are missing or the
  station uses a static IP; DHCP wins on conflict.

Default DHCPLeasesPath updated to /var/lib/udhcpd/udhcpd.leases — the
common BusyBox path. Configurable as before.
2026-05-02 11:07:37 +08:00
cmd/repeater station: Identify devices by MAC OUI vendor lookup 2026-05-01 22:32:57 +08:00
internal station/hostapd: Resolve station IPs via udhcpd leases and ARP fallback 2026-05-02 11:07:37 +08:00
.gitignore Migrate to a better architectured project 2026-01-01 23:31:01 +07:00
generate.go Add OpenAPI specs 2025-10-28 18:25:45 +07:00
go.mod Migrate to a better architectured project 2026-01-01 23:31:01 +07:00
go.sum Add OpenAPI specs 2025-10-28 18:25:45 +07:00
Makefile Migrate to a better architectured project 2026-01-01 23:31:01 +07:00
oapi-gin.cfg.yaml Add OpenAPI specs 2025-10-28 18:25:45 +07:00
oapi-types.cfg.yaml Add OpenAPI specs 2025-10-28 18:25:45 +07:00
openapi.yaml station: Surface signal, traffic and connection time in API and UI 2026-05-01 22:26:43 +08:00
README.md Migrate to a better architectured project 2026-01-01 23:31:01 +07:00

Travel Router Control

A Go application for controlling a mini travel router with dual WiFi interfaces and Ethernet connectivity. The router can operate as a WiFi repeater, connecting to upstream networks while providing a hotspot for client devices.

Features

  • WiFi network scanning and connection management
  • Hotspot (access point) configuration and control
  • Connected device monitoring
  • Real-time system logs via WebSocket
  • RESTful API following OpenAPI 3.0 specification
  • Web interface for easy management

Architecture

The application follows a clean architecture pattern:

.
├── cmd/
│   └── repeater/          # Application entry point
│       ├── main.go
│       └── static/        # Embedded web assets
├── internal/
│   ├── api/              # HTTP API layer
│   │   ├── router.go     # Gin router setup
│   │   └── handlers/     # HTTP handlers
│   ├── app/              # Application logic & lifecycle
│   ├── device/           # Device management
│   ├── hotspot/          # Hotspot control
│   ├── logging/          # Logging system
│   ├── models/           # Data structures
│   └── wifi/             # WiFi operations (wpa_supplicant via D-Bus)
├── openapi.yaml          # API specification
└── go.mod

Building

go build -o repeater ./cmd/repeater

Running

sudo ./repeater

The application requires root privileges to:

  • Access D-Bus system bus for wpa_supplicant
  • Control systemd services (hostapd)
  • Read DHCP leases and ARP tables

The server will start on port 8080.

API Endpoints

WiFi Operations

  • GET /api/wifi/scan - Scan for available networks
  • POST /api/wifi/connect - Connect to a network
  • POST /api/wifi/disconnect - Disconnect from current network

Hotspot Operations

  • POST /api/hotspot/config - Configure hotspot settings
  • POST /api/hotspot/toggle - Enable/disable hotspot

Device Management

  • GET /api/devices - Get connected devices

System

  • GET /api/status - Get system status
  • GET /api/logs - Get system logs
  • DELETE /api/logs - Clear logs

WebSocket

  • GET /ws/logs - Real-time log streaming

See openapi.yaml for complete API documentation.

Configuration

The application uses the following system resources:

  • WiFi Interface: wlan0 (for upstream connection)
  • AP Interface: wlan1 (for hotspot)
  • Hostapd Config: /etc/hostapd/hostapd.conf
  • WPA Supplicant Config: /etc/wpa_supplicant/wpa_supplicant.conf

These can be modified in the respective package constants.

Dependencies

  • Gin: HTTP web framework
  • godbus: D-Bus client for wpa_supplicant control
  • gorilla/websocket: WebSocket support
  • wpa_supplicant: WiFi connection management
  • hostapd: Hotspot functionality

License

MIT