diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-17 16:29:58 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-17 16:35:02 -0500 |
commit | 9db6018c00e4d6a7bba2ba0228b65cd3a1dfcbb7 (patch) | |
tree | a7fd7e46a1d16c75641d1ec1754c386e16984cd0 /src | |
parent | b977caa5759685e2a8f969f099c1293cb810f07c (diff) | |
download | wg2nd-9db6018c00e4d6a7bba2ba0228b65cd3a1dfcbb7.tar.xz wg2nd-9db6018c00e4d6a7bba2ba0228b65cd3a1dfcbb7.zip |
Add ListenPort to netdev config and ensure that Endpoint is not present if not specified
Diffstat (limited to 'src')
-rw-r--r-- | src/wg2sd.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wg2sd.cpp b/src/wg2sd.cpp index 2571908..23c6546 100644 --- a/src/wg2sd.cpp +++ b/src/wg2sd.cpp @@ -307,6 +307,10 @@ namespace wg2sd { netdev << private_keyfile << "\n"; + if(cfg.intf.listen_port.has_value()) { + netdev << "ListenPort = " << cfg.intf.listen_port.value() << "\n"; + } + if(cfg.intf.should_create_routes and cfg.intf.table != 0) { netdev << "RouteTable = "; @@ -333,10 +337,12 @@ namespace wg2sd { for(Peer const & peer : cfg.peers) { netdev << "[WireGuardPeer]\n"; - - netdev << "Endpoint = " << peer.endpoint << "\n"; netdev << "PublicKey = " << peer.public_key << "\n"; + if(!peer.endpoint.empty()) { + netdev << "Endpoint = " << peer.endpoint << "\n"; + } + if(!peer.preshared_key.empty()) { std::string filename = hashed_keyfile_name(peer.preshared_key); |