configurable excludeIP for ezwg

This commit is contained in:
notgne2 2021-06-27 02:08:53 -07:00
parent 7604d2d7d7
commit 1da2d8a098
No known key found for this signature in database
GPG Key ID: BB661E172B42A7F8

View File

@ -24,6 +24,12 @@ in
description = "The IP of the wg server"; description = "The IP of the wg server";
}; };
excludeIP = mkOption {
type = types.str;
default = cfg.serverIP;
description = "The IP to _not_ route through the proxy, you normally want this to be the same as `serverIP` when not tunneling";
};
serverPort = mkOption { serverPort = mkOption {
type = types.int; type = types.int;
default = 51820; default = 51820;
@ -54,7 +60,7 @@ in
builtins.toFile "exclusionary-wildcard-ranges-generator.py" '' builtins.toFile "exclusionary-wildcard-ranges-generator.py" ''
import ipaddress import ipaddress
n1 = ipaddress.ip_network('0.0.0.0/0') n1 = ipaddress.ip_network('0.0.0.0/0')
n2 = ipaddress.ip_network('${cfg.serverIP}/32') n2 = ipaddress.ip_network('${cfg.excludeIP}/32')
print(':'.join(list(map(lambda x: str(x), list(n1.address_exclude(n2))))), end="") print(':'.join(list(map(lambda x: str(x), list(n1.address_exclude(n2))))), end="")
''; '';