mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
[code-quality] fix clang-tidy wireguard (#7287)
This commit is contained in:
parent
ecd3d838c9
commit
965141fad7
4 changed files with 15 additions and 8 deletions
|
@ -1,19 +1,20 @@
|
||||||
import re
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import re
|
||||||
|
|
||||||
|
from esphome import automation
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
from esphome.components import time
|
||||||
|
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ID,
|
|
||||||
CONF_TIME_ID,
|
|
||||||
CONF_ADDRESS,
|
CONF_ADDRESS,
|
||||||
|
CONF_ID,
|
||||||
CONF_REBOOT_TIMEOUT,
|
CONF_REBOOT_TIMEOUT,
|
||||||
|
CONF_TIME_ID,
|
||||||
KEY_CORE,
|
KEY_CORE,
|
||||||
KEY_FRAMEWORK_VERSION,
|
KEY_FRAMEWORK_VERSION,
|
||||||
)
|
)
|
||||||
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
|
|
||||||
from esphome.components import time
|
|
||||||
from esphome.core import TimePeriod
|
from esphome.core import TimePeriod
|
||||||
from esphome import automation
|
|
||||||
|
|
||||||
CONF_NETMASK = "netmask"
|
CONF_NETMASK = "netmask"
|
||||||
CONF_PRIVATE_KEY = "private_key"
|
CONF_PRIVATE_KEY = "private_key"
|
||||||
|
@ -91,6 +92,8 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
|
||||||
|
cg.add_define("USE_WIREGUARD")
|
||||||
|
|
||||||
cg.add(var.set_address(str(config[CONF_ADDRESS])))
|
cg.add(var.set_address(str(config[CONF_ADDRESS])))
|
||||||
cg.add(var.set_netmask(str(config[CONF_NETMASK])))
|
cg.add(var.set_netmask(str(config[CONF_NETMASK])))
|
||||||
cg.add(var.set_private_key(config[CONF_PRIVATE_KEY]))
|
cg.add(var.set_private_key(config[CONF_PRIVATE_KEY]))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "wireguard.h"
|
#include "wireguard.h"
|
||||||
|
#ifdef USE_WIREGUARD
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -289,3 +289,4 @@ std::string mask_key(const std::string &key) { return (key.substr(0, 5) + "[...]
|
||||||
|
|
||||||
} // namespace wireguard
|
} // namespace wireguard
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
|
#ifdef USE_WIREGUARD
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
@ -170,3 +171,4 @@ template<typename... Ts> class WireguardDisableAction : public Action<Ts...>, pu
|
||||||
|
|
||||||
} // namespace wireguard
|
} // namespace wireguard
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
#endif
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
#define USE_VALVE
|
#define USE_VALVE
|
||||||
#define USE_WIFI
|
#define USE_WIFI
|
||||||
#define USE_WIFI_AP
|
#define USE_WIFI_AP
|
||||||
|
#define USE_WIREGUARD
|
||||||
|
|
||||||
// Arduino-specific feature flags
|
// Arduino-specific feature flags
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
|
|
Loading…
Reference in a new issue