aboutsummaryrefslogtreecommitdiff
path: root/src/wg2sd.cpp
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-17 16:29:58 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-17 16:35:02 -0500
commit9db6018c00e4d6a7bba2ba0228b65cd3a1dfcbb7 (patch)
treea7fd7e46a1d16c75641d1ec1754c386e16984cd0 /src/wg2sd.cpp
parentb977caa5759685e2a8f969f099c1293cb810f07c (diff)
downloadwg2nd-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/wg2sd.cpp')
-rw-r--r--src/wg2sd.cpp10
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);