No description
- Go 73.7%
- JavaScript 14.8%
- CSS 7.9%
- HTML 3.4%
- Makefile 0.2%
probeEthernet looked for a "DHCP-assigned" address using the `dynamic` flag or a finite `valid_lft`. udhcpc (BusyBox) installs the leased address with a plain `ip addr add` and no lease lifetime, so the address shows `valid_lft forever` and no `dynamic` flag — indistinguishable from a static LAN/hotspot address on the same interface. The uplink was never recognized and wpa_supplicant was started despite working connectivity. Detect the uplink via the interface's default route instead, which is reliable across udhcpc and full iproute2, and report the uplink source address from `ip route get` so the UI shows the DHCP address rather than a co-located static one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| cmd/repeater | ||
| internal | ||
| .gitignore | ||
| generate.go | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| oapi-gin.cfg.yaml | ||
| oapi-types.cfg.yaml | ||
| openapi.yaml | ||
| README.md | ||
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 networksPOST /api/wifi/connect- Connect to a networkPOST /api/wifi/disconnect- Disconnect from current network
Hotspot Operations
POST /api/hotspot/config- Configure hotspot settingsPOST /api/hotspot/toggle- Enable/disable hotspot
Device Management
GET /api/devices- Get connected devices
System
GET /api/status- Get system statusGET /api/logs- Get system logsDELETE /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