Skip to content

feat: add optional WireGuard client for repeater MQTT - #18

Open
Misheldeep wants to merge 2 commits into
VBart:mainfrom
Misheldeep:feature/wireguard-client
Open

Misheldeep wants to merge 2 commits into
VBart:mainfrom
Misheldeep:feature/wireguard-client

Conversation

@Misheldeep

Copy link
Copy Markdown

Summary

Adds an optional WireGuard client for ESP32 repeater MQTT builds.

The feature is disabled by default and enabled with a dedicated heltec_v4_repeater_mqtt_wireguard PlatformIO environment. WireGuard settings are stored in NVS and managed through the existing CLI.

What it adds

  • persistent local private key with generated public key
  • configurable peer public key, endpoint and tunnel address
  • split-tunnel setup that keeps Wi-Fi as the default route
  • retry after startup/network loss without affecting LoRa or MQTT operation
  • get wg.status with peer/session/RX/TX age diagnostics
  • CLI documentation
  • vendored WireGuard-ESP32-Arduino 0.1.5 with its BSD-3-Clause license retained
  • two small local library extensions:
    • explicit subnet/gateway support for the WireGuard interface
    • peer/session status reporting

CLI

get wg.public
get wg.private
get wg.peer
get wg.endpoint
get wg.address
get wg.status

set wg.private <base64-private-key>
set wg.private generate
set wg.peer <base64-public-key>
set wg.endpoint <hostname-or-ip>
set wg.endpoint clear
set wg.address <IPv4>/<prefix>

The peer public key, endpoint and tunnel address are intentionally not hard-coded.

Routing behavior

The WireGuard interface receives only its configured tunnel subnet. After interface creation, the Wi-Fi STA interface is restored as the lwIP default route, so MQTT/NTP/general Internet traffic continues to use the existing Wi-Fi uplink.

WireGuard failure therefore does not make the repeater depend on the tunnel for normal operation.

Validation

Built successfully on the current main base:

  • heltec_v4_repeater_mqtt
  • heltec_v4_repeater_mqtt_wireguard

The implementation has also been exercised on a Heltec V4.3 repeater with remote web/CLI access through WireGuard while MQTT remained on the normal Internet path.

This PR deliberately does not include the separate experimental web-server socket-count change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant