From 933ad2aeda754499753e91be05aa9f5556539d35 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 8 Jan 2019 19:24:13 +0100 Subject: [feat] reload firewall with SIGUSR1 - Resolves: riseup_vpn#46 --- standalone/vpn.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'standalone/vpn.go') 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() -- cgit v1.2.3