Fix wireguard config syntax
This commit is contained in:
parent
d0084adcc9
commit
9b0c68540e
1 changed files with 41 additions and 37 deletions
|
|
@ -131,12 +131,18 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
# Server configuration
|
||||
networking.wg-quick.interfaces = mkIf (cfg.mode == "server") {
|
||||
${cfg.interface} = {
|
||||
# WireGuard interface configuration (combined server and client)
|
||||
networking.wg-quick.interfaces = {
|
||||
${cfg.interface} = mkMerge [
|
||||
# Common configuration
|
||||
{
|
||||
privateKeyFile = cfg.privateKeyFile;
|
||||
}
|
||||
|
||||
# Server-specific configuration
|
||||
(mkIf (cfg.mode == "server") {
|
||||
address = [ cfg.serverConfig.address ];
|
||||
listenPort = cfg.listenPort;
|
||||
privateKeyFile = cfg.privateKeyFile;
|
||||
|
||||
# Enable IP forwarding and NAT for server
|
||||
preUp = ''
|
||||
|
|
@ -155,14 +161,11 @@ in
|
|||
publicKey = peer.publicKey;
|
||||
allowedIPs = peer.allowedIPs;
|
||||
}) cfg.serverConfig.peers;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
# Client configuration
|
||||
networking.wg-quick.interfaces = mkIf (cfg.mode == "client") {
|
||||
${cfg.interface} = {
|
||||
# Client-specific configuration
|
||||
(mkIf (cfg.mode == "client") {
|
||||
address = [ cfg.clientConfig.address ];
|
||||
privateKeyFile = cfg.privateKeyFile;
|
||||
|
||||
peers = [{
|
||||
publicKey = cfg.clientConfig.serverPublicKey;
|
||||
|
|
@ -170,7 +173,8 @@ in
|
|||
endpoint = cfg.clientConfig.serverEndpoint;
|
||||
persistentKeepalive = 25;
|
||||
}];
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
# Firewall configuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue