mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
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:
parent
41e13fa6f4
commit
2beb1f0336
3 changed files with 65 additions and 4 deletions
|
@ -122,7 +122,7 @@ async def to_code(config):
|
||||||
# the '+1' modifier is relative to the device's own address that will
|
# the '+1' modifier is relative to the device's own address that will
|
||||||
# be automatically added to the provided list.
|
# be automatically added to the provided list.
|
||||||
cg.add_build_flag(f"-DCONFIG_WIREGUARD_MAX_SRC_IPS={len(allowed_ips) + 1}")
|
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)
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ lib_deps =
|
||||||
ESP8266mDNS ; mdns (Arduino built-in)
|
ESP8266mDNS ; mdns (Arduino built-in)
|
||||||
DNSServer ; captive_portal (Arduino built-in)
|
DNSServer ; captive_portal (Arduino built-in)
|
||||||
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
|
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
|
||||||
droscy/esp_wireguard@0.4.0 ; wireguard
|
droscy/esp_wireguard@0.4.1 ; wireguard
|
||||||
build_flags =
|
build_flags =
|
||||||
${common:arduino.build_flags}
|
${common:arduino.build_flags}
|
||||||
-Wno-nonnull-compare
|
-Wno-nonnull-compare
|
||||||
|
@ -124,7 +124,7 @@ lib_deps =
|
||||||
DNSServer ; captive_portal (Arduino built-in)
|
DNSServer ; captive_portal (Arduino built-in)
|
||||||
esphome/ESP32-audioI2S@2.0.7 ; i2s_audio
|
esphome/ESP32-audioI2S@2.0.7 ; i2s_audio
|
||||||
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
|
crankyoldgit/IRremoteESP8266@~2.8.4 ; heatpumpir
|
||||||
droscy/esp_wireguard@0.4.0 ; wireguard
|
droscy/esp_wireguard@0.4.1 ; wireguard
|
||||||
build_flags =
|
build_flags =
|
||||||
${common:arduino.build_flags}
|
${common:arduino.build_flags}
|
||||||
-DUSE_ESP32
|
-DUSE_ESP32
|
||||||
|
@ -143,7 +143,7 @@ framework = espidf
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common:idf.lib_deps}
|
${common:idf.lib_deps}
|
||||||
espressif/esp32-camera@1.0.0 ; esp32_camera
|
espressif/esp32-camera@1.0.0 ; esp32_camera
|
||||||
droscy/esp_wireguard@0.4.0 ; wireguard
|
droscy/esp_wireguard@0.4.1 ; wireguard
|
||||||
build_flags =
|
build_flags =
|
||||||
${common:idf.build_flags}
|
${common:idf.build_flags}
|
||||||
-Wno-nonnull-compare
|
-Wno-nonnull-compare
|
||||||
|
@ -174,6 +174,8 @@ build_flags =
|
||||||
extends = common:arduino
|
extends = common:arduino
|
||||||
platform = libretiny
|
platform = libretiny
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
lib_deps =
|
||||||
|
droscy/esp_wireguard@0.4.1 ; wireguard
|
||||||
build_flags =
|
build_flags =
|
||||||
${common:arduino.build_flags}
|
${common:arduino.build_flags}
|
||||||
-DUSE_LIBRETINY
|
-DUSE_LIBRETINY
|
||||||
|
|
59
tests/components/wireguard/test.bk72xx.yaml
Normal file
59
tests/components/wireguard/test.bk72xx.yaml
Normal 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'
|
Loading…
Reference in a new issue