#include <WireguardBackend.hpp>
Public Member Functions | |
| WireguardBackend (std::string iface="wg0") | |
| bool | tooling_available (std::string *missing=nullptr) const |
| bool | load_from_conf (const std::string &conf_path, std::string *err=nullptr) |
| bool | load_from_params (const WgConfigParams &p, std::string *err=nullptr) |
| bool | has_spec () const |
| std::string | configured_endpoint () const |
| std::optional< WgKeyPair > | generate_keys () const |
| OpResult | connect () |
| OpResult | disconnect () |
| WgStatus | status () const |
| std::optional< std::string > | public_ip () const |
| OpResult | killswitch_enable () |
| OpResult | killswitch_disable () |
| bool | killswitch_active () const |
| const std::string & | interface_name () const |
Private Member Functions | |
| OpResult | run (const std::vector< std::string > &argv, bool privileged) const |
| OpResult | run_with_stdin (const std::vector< std::string > &argv, const std::string &stdin_data, bool privileged) const |
| std::string | build_wg_setconf_text () const |
Private Attributes | |
| std::string | iface_ |
| WgTunnelSpec | spec_ |
Definition at line 95 of file WireguardBackend.hpp.
|
explicit |
Definition at line 27 of file WireguardBackend.cpp.
References iface_.
|
private |
Definition at line 371 of file WireguardBackend.cpp.
References BastionGuard::WgTunnelSpec::listen_port, BastionGuard::WgTunnelSpec::peers, BastionGuard::WgTunnelSpec::private_key, and spec_.
Referenced by connect().
|
inline |
Definition at line 115 of file WireguardBackend.hpp.
References BastionGuard::WgTunnelSpec::peers, and spec_.
| OpResult BastionGuard::WireguardBackend::connect | ( | ) |
Definition at line 404 of file WireguardBackend.cpp.
References BastionGuard::WgTunnelSpec::addresses, build_wg_setconf_text(), BastionGuard::WgTunnelSpec::dns, BastionGuard::OpResult::exit_code, iface_, BastionGuard::WgTunnelSpec::mtu, BastionGuard::needs_default_route_(), BastionGuard::OpResult::ok, BastionGuard::OpResult::output, BastionGuard::WgTunnelSpec::peers, run(), run_with_stdin(), spec_, BastionGuard::split_csv_(), BastionGuard::valid_iface_(), and BastionGuard::validate_spec_().
| OpResult BastionGuard::WireguardBackend::disconnect | ( | ) |
Definition at line 491 of file WireguardBackend.cpp.
References iface_, BastionGuard::OpResult::ok, and run().
| std::optional< WgKeyPair > BastionGuard::WireguardBackend::generate_keys | ( | ) | const |
Definition at line 356 of file WireguardBackend.cpp.
References BastionGuard::OpResult::ok, BastionGuard::OpResult::output, run(), run_with_stdin(), and BastionGuard::strip_().
|
inline |
Definition at line 111 of file WireguardBackend.hpp.
References spec_, and BastionGuard::WgTunnelSpec::valid().
|
inline |
| bool BastionGuard::WireguardBackend::killswitch_active | ( | ) | const |
Definition at line 618 of file WireguardBackend.cpp.
References BastionGuard::kKsTable, and run().
| OpResult BastionGuard::WireguardBackend::killswitch_disable | ( | ) |
Definition at line 608 of file WireguardBackend.cpp.
References BastionGuard::kKsTable, and run().
| OpResult BastionGuard::WireguardBackend::killswitch_enable | ( | ) |
Definition at line 570 of file WireguardBackend.cpp.
References AF_INET, AF_INET6, BastionGuard::WgStatus::endpoint, iface_, BastionGuard::kKsTable, run_with_stdin(), status(), and BastionGuard::valid_iface_().
| bool BastionGuard::WireguardBackend::load_from_conf | ( | const std::string & | conf_path, |
| std::string * | err = nullptr ) |
Definition at line 266 of file WireguardBackend.cpp.
References BastionGuard::WgTunnelSpec::addresses, BastionGuard::WgPeer::allowed_ips, BastionGuard::WgTunnelSpec::dns, BastionGuard::WgPeer::endpoint, BastionGuard::WgTunnelSpec::listen_port, BastionGuard::WgTunnelSpec::mtu, BastionGuard::WgTunnelSpec::peers, BastionGuard::WgPeer::persistent_keepalive, BastionGuard::WgPeer::preshared_key, BastionGuard::WgTunnelSpec::private_key, BastionGuard::WgPeer::public_key, spec_, BastionGuard::split_csv_(), BastionGuard::strip_(), and BastionGuard::validate_spec_().
| bool BastionGuard::WireguardBackend::load_from_params | ( | const WgConfigParams & | p, |
| std::string * | err = nullptr ) |
Definition at line 327 of file WireguardBackend.cpp.
References BastionGuard::WgConfigParams::address, BastionGuard::WgTunnelSpec::addresses, BastionGuard::WgConfigParams::allowed_ips, BastionGuard::WgPeer::allowed_ips, BastionGuard::WgConfigParams::dns, BastionGuard::WgTunnelSpec::dns, BastionGuard::WgConfigParams::endpoint, BastionGuard::WgPeer::endpoint, BastionGuard::WgConfigParams::listen_port, BastionGuard::WgTunnelSpec::listen_port, BastionGuard::WgTunnelSpec::peers, BastionGuard::WgConfigParams::persistent_keepalive, BastionGuard::WgPeer::persistent_keepalive, BastionGuard::WgConfigParams::private_key, BastionGuard::WgTunnelSpec::private_key, BastionGuard::WgPeer::public_key, BastionGuard::WgConfigParams::server_public_key, spec_, BastionGuard::split_csv_(), and BastionGuard::validate_spec_().
| std::optional< std::string > BastionGuard::WireguardBackend::public_ip | ( | ) | const |
Definition at line 545 of file WireguardBackend.cpp.
References run(), and BastionGuard::strip_().
|
private |
Definition at line 33 of file WireguardBackend.cpp.
References BastionGuard::OpResult::exit_code, BastionGuard::OpResult::ok, and BastionGuard::OpResult::output.
Referenced by connect(), disconnect(), generate_keys(), killswitch_active(), killswitch_disable(), public_ip(), and status().
|
private |
Definition at line 57 of file WireguardBackend.cpp.
References BastionGuard::OpResult::exit_code, BastionGuard::OpResult::ok, BastionGuard::OpResult::output, and status().
Referenced by connect(), generate_keys(), and killswitch_enable().
| WgStatus BastionGuard::WireguardBackend::status | ( | ) | const |
Definition at line 518 of file WireguardBackend.cpp.
References BastionGuard::WgStatus::endpoint, iface_, BastionGuard::WgStatus::interface, BastionGuard::WgStatus::last_handshake, BastionGuard::OpResult::ok, run(), BastionGuard::strip_(), and BastionGuard::WgStatus::up.
Referenced by killswitch_enable(), and run_with_stdin().
| bool BastionGuard::WireguardBackend::tooling_available | ( | std::string * | missing = nullptr | ) | const |
Definition at line 125 of file WireguardBackend.cpp.
References BastionGuard::in_path_().
|
private |
Definition at line 140 of file WireguardBackend.hpp.
Referenced by connect(), disconnect(), interface_name(), killswitch_enable(), status(), and WireguardBackend().
|
private |
Definition at line 141 of file WireguardBackend.hpp.
Referenced by build_wg_setconf_text(), configured_endpoint(), connect(), has_spec(), load_from_conf(), and load_from_params().