Wireguard support for bk72 microcontrollers (#6842)

* Bump esp_wireguard to v0.4.1

* add support for bk72 microcontrollers (thanks to kuba2k2)
* fix compilation error using esp-idf v5 (thanks to kbx81)
* fix crash on vpn disconnection with alive tcp connection (thanks to jefftharris)

* Disable ipv6 for bk72 wireguard test

* Completely remove ipv6 entry from bk72 wg test
This commit is contained in:
Simone Rossetto 2024-06-01 04:36:51 +02:00 committed by GitHub
parent 41e13fa6f4
commit 2beb1f0336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 65 additions and 4 deletions

View file

@ -122,7 +122,7 @@ async def to_code(config):
# the '+1' modifier is relative to the device's own address that will
# be automatically added to the provided list.
cg.add_build_flag(f"-DCONFIG_WIREGUARD_MAX_SRC_IPS={len(allowed_ips) + 1}")
cg.add_library("droscy/esp_wireguard", "0.4.0")
cg.add_library("droscy/esp_wireguard", "0.4.1")
await cg.register_component(var, config)

View file

@ -94,7 +94,7 @@ lib_deps =
ESP8266mDNS ; mdns (Arduino built-in)
DNSServer ; captive_portal (Arduino built-in)
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
droscy/esp_wireguard@0.4.0 ; wireguard
droscy/esp_wireguard@0.4.1 ; wireguard
build_flags =
${common:arduino.build_flags}
-Wno-nonnull-compare
@ -124,7 +124,7 @@ lib_deps =
DNSServer ; captive_portal (Arduino built-in)
esphome/ESP32-audioI2S@2.0.7 ; i2s_audio
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
droscy/esp_wireguard@0.4.0 ; wireguard
droscy/esp_wireguard@0.4.1 ; wireguard
build_flags =
${common:arduino.build_flags}
-DUSE_ESP32
@ -143,7 +143,7 @@ framework = espidf
lib_deps =
${common:idf.lib_deps}
espressif/esp32-camera@1.0.0 ; esp32_camera
droscy/esp_wireguard@0.4.0 ; wireguard
droscy/esp_wireguard@0.4.1 ; wireguard
build_flags =
${common:idf.build_flags}
-Wno-nonnull-compare
@ -174,6 +174,8 @@ build_flags =
extends = common:arduino
platform = libretiny
framework = arduino
lib_deps =
droscy/esp_wireguard@0.4.1 ; wireguard
build_flags =
${common:arduino.build_flags}
-DUSE_LIBRETINY

View file

@ -0,0 +1,59 @@
wifi:
ssid: "MySSID1"
password: "password1"
time:
- platform: sntp
wireguard:
address: 172.16.34.100
netmask: 255.255.255.0
# NEVER use the following keys for your vpn, they are now public!
private_key: wPBMxtNYH3mChicrbpsRpZIasIdPq3yZuthn23FbGG8=
peer_public_key: Hs2JfikvYU03/Kv3YoAs1hrUIPPTEkpsZKSPUljE9yc=
peer_preshared_key: 20fjM5GRnSolGPC5SRj9ljgIUyQfruv0B0bvLl3Yt60=
peer_endpoint: wg.server.example
peer_persistent_keepalive: 25s
peer_allowed_ips:
- 172.16.34.0/24
- 192.168.4.0/24
binary_sensor:
- platform: wireguard
status:
name: 'WireGuard Status'
enabled:
name: 'WireGuard Enabled'
sensor:
- platform: wireguard
latest_handshake:
name: 'WireGuard Latest Handshake'
text_sensor:
- platform: wireguard
address:
name: 'WireGuard Address'
button:
- platform: template
name: 'Toggle WireGuard'
entity_category: config
on_press:
- if:
condition: wireguard.enabled
then:
- wireguard.disable:
else:
- wireguard.enable:
- platform: template
name: 'Log WireGuard status'
entity_category: config
on_press:
- if:
condition: wireguard.peer_online
then:
- logger.log: 'wireguard remote peer is online'
else:
- logger.log: 'wireguard remote peer is offline'