aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-21 15:45:08 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-22 22:00:32 +0100
commit224336aa077020c35d3feb8a534f92c814b232e9 (patch)
treea6b366f7061ba69c31138b1961f30994b9dfc38e /conf
parentconf: allow administrators to add and remove configs easily (diff)
downloadwireguard-windows-224336aa077020c35d3feb8a534f92c814b232e9.tar.xz
wireguard-windows-224336aa077020c35d3feb8a534f92c814b232e9.zip
tunnel: enable {Pre,Post}{Up,Down} scripts gated behind admin knob
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf')
-rw-r--r--conf/config.go4
-rw-r--r--conf/filewriter_windows.go2
-rw-r--r--conf/parser.go8
-rw-r--r--conf/writer.go13
4 files changed, 26 insertions, 1 deletions
diff --git a/conf/config.go b/conf/config.go
index 1ce1988d..9eb6157e 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -49,6 +49,10 @@ type Interface struct {
MTU uint16
DNS []net.IP
DNSSearch []string
+ PreUp string
+ PostUp string
+ PreDown string
+ PostDown string
}
type Peer struct {
diff --git a/conf/filewriter_windows.go b/conf/filewriter_windows.go
index 9fb1f566..8860ba31 100644
--- a/conf/filewriter_windows.go
+++ b/conf/filewriter_windows.go
@@ -69,4 +69,4 @@ func writeEncryptedFile(destination string, contents []byte) error {
return err
}
return nil
-} \ No newline at end of file
+}
diff --git a/conf/parser.go b/conf/parser.go
index da21e796..17b0e21f 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -282,6 +282,14 @@ func FromWgQuick(s string, name string) (*Config, error) {
conf.Interface.DNS = append(conf.Interface.DNS, a)
}
}
+ case "preup":
+ conf.Interface.PreUp = val
+ case "postup":
+ conf.Interface.PostUp = val
+ case "predown":
+ conf.Interface.PreDown = val
+ case "postdown":
+ conf.Interface.PostDown = val
default:
return nil, &ParseError{l18n.Sprintf("Invalid key for [Interface] section"), key}
}
diff --git a/conf/writer.go b/conf/writer.go
index 365e65e9..6b16f843 100644
--- a/conf/writer.go
+++ b/conf/writer.go
@@ -41,6 +41,19 @@ func (conf *Config) ToWgQuick() string {
output.WriteString(fmt.Sprintf("MTU = %d\n", conf.Interface.MTU))
}
+ if len(conf.Interface.PreUp) > 0 {
+ output.WriteString(fmt.Sprintf("PreUp = %s\n", conf.Interface.PreUp))
+ }
+ if len(conf.Interface.PostUp) > 0 {
+ output.WriteString(fmt.Sprintf("PostUp = %s\n", conf.Interface.PostUp))
+ }
+ if len(conf.Interface.PreDown) > 0 {
+ output.WriteString(fmt.Sprintf("PreDown = %s\n", conf.Interface.PreDown))
+ }
+ if len(conf.Interface.PostDown) > 0 {
+ output.WriteString(fmt.Sprintf("PostDown = %s\n", conf.Interface.PostDown))
+ }
+
for _, peer := range conf.Peers {
output.WriteString("\n[Peer]\n")