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