summaryrefslogtreecommitdiff
path: root/standalone
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2019-01-08 19:24:13 +0100
committerKali Kaneko (leap communications) <kali@leap.se>2019-01-12 18:25:42 +0100
commit933ad2aeda754499753e91be05aa9f5556539d35 (patch)
treeacb104e4a984e67fc007037ed55e3b6182ee8b91 /standalone
parentf274ec2beaf060cc8bfe4f5eb6f2ce3b5c6aa1f3 (diff)
[feat] reload firewall with SIGUSR1
- Resolves: riseup_vpn#46
Diffstat (limited to 'standalone')
-rw-r--r--standalone/vpn.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/standalone/vpn.go b/standalone/vpn.go
index 0ff090c..c3b2693 100644
--- a/standalone/vpn.go
+++ b/standalone/vpn.go
@@ -82,6 +82,28 @@ func (b *Bitmask) StopVPN() error {
return b.launch.openvpnStop()
}
+// ReloadFirewall restarts the firewall
+func (b *Bitmask) ReloadFirewall() error {
+ err := b.launch.firewallStop()
+ if err != nil {
+ return err
+ }
+
+ status, err := b.GetStatus()
+ if err != nil {
+ return err
+ }
+
+ if status != Off {
+ gateways, err := b.bonafide.getGateways()
+ if err != nil {
+ return err
+ }
+ return b.launch.firewallStart(gateways)
+ }
+ return nil
+}
+
// GetStatus returns the VPN status
func (b *Bitmask) GetStatus() (string, error) {
status, err := b.getOpenvpnState()