11#ifdef USE_BINARY_SENSOR
23#include <esp_wireguard.h>
31 void setup()
override;
48 void add_allowed_ip(
const std::string &ip,
const std::string &netmask);
54#ifdef USE_BINARY_SENSOR
101#ifdef USE_BINARY_SENSOR
110#ifdef USE_TEXT_SENSOR
120 wireguard_config_t
wg_config_ = ESP_WIREGUARD_CONFIG_DEFAULT();
121 wireguard_ctx_t
wg_ctx_ = ESP_WIREGUARD_CONTEXT_DEFAULT();
146std::string
mask_key(
const std::string &key);
Base class for all automation conditions.
Helper class to easily give an object a parent of type T.
This class simplifies creating components that periodically check a state.
Base class for all binary_sensor-type classes.
Base-class for all sensors.
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
Action to disable Wireguard component.
void play(const Ts &...x) override
Action to enable Wireguard component.
void play(const Ts &...x) override
Condition to check if Wireguard component is enabled.
bool check(const Ts &...x) override
Main Wireguard component class.
binary_sensor::BinarySensor * enabled_sensor_
void set_keepalive(uint16_t seconds)
bool enabled_
When false the wireguard link will not be established.
binary_sensor::BinarySensor * status_sensor_
float get_setup_priority() const override
void set_peer_public_key(const std::string &key)
void set_status_sensor(binary_sensor::BinarySensor *sensor)
std::string peer_public_key_
void set_srctime(time::RealTimeClock *srctime)
void publish_enabled_state()
Publish the enabled state if the enabled binary sensor is configured.
time_t get_latest_handshake() const
void on_shutdown() override
void add_allowed_ip(const std::string &ip, const std::string &netmask)
sensor::Sensor * handshake_sensor_
time::RealTimeClock * srctime_
bool proceed_allowed_
Set to false to block the setup step until peer is connected.
void dump_config() override
std::vector< std::tuple< std::string, std::string > > allowed_ips_
void set_reboot_timeout(uint32_t seconds)
void set_peer_endpoint(const std::string &endpoint)
void set_private_key(const std::string &key)
void disable_auto_proceed()
Block the setup step until peer is connected.
bool can_proceed() override
std::string peer_endpoint_
void set_preshared_key(const std::string &key)
void set_address_sensor(text_sensor::TextSensor *sensor)
std::string preshared_key_
text_sensor::TextSensor * address_sensor_
uint32_t wg_peer_offline_time_
The last time the remote peer become offline.
void disable()
Stop any running connection and disable the WireGuard component.
void set_enabled_sensor(binary_sensor::BinarySensor *sensor)
void set_handshake_sensor(sensor::Sensor *sensor)
void set_address(const std::string &address)
esp_err_t wg_initialized_
bool is_enabled()
Return if the WireGuard component is or is not enabled.
void enable()
Enable the WireGuard component.
void set_peer_port(uint16_t port)
void set_netmask(const std::string &netmask)
time_t latest_saved_handshake_
The latest saved handshake.
wireguard_config_t wg_config_
Condition to check if remote peer is online.
bool check(const Ts &...x) override
const float BEFORE_CONNECTION
For components that should be initialized after WiFi and before API is connected.
std::string mask_key(const std::string &key)
Strip most part of the key only for secure printing.
Providing packet encoding functions for exchanging data with a remote host.