Skip to content
Snippets Groups Projects
Unverified Commit f274ec2b authored by meskio's avatar meskio :tent:
Browse files

[feat] use firewall status to check if the vpn is in failed status

If openvpn is off, but the firewall is up, we are in a fail-close status
and we should report it properly.

- Resolves: #97
parent 9434d253
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,16 @@ func (l *launcher) firewallStop() error {
return l.send("/firewall/stop", nil)
}
func (l *launcher) firewallIsUp() bool {
res, err := http.Post(helperAddr+"/firewall/isup", "", nil)
if err != nil {
return false
}
defer res.Body.Close()
return res.StatusCode == http.StatusOK
}
func (l *launcher) send(path string, body []byte) error {
var reader io.Reader
if body != nil {
......
......@@ -75,6 +75,11 @@ func (l *launcher) firewallStop() error {
return runBitmaskRoot("firewall", "stop")
}
func (l *launcher) firewallIsUp() bool {
err := runBitmaskRoot("firewall", "isup")
return err == nil
}
func (l *launcher) openvpnRunner(arg ...string) {
running := false
runOpenvpn := func(arg []string) {
......
......@@ -88,6 +88,9 @@ func (b *Bitmask) GetStatus() (string, error) {
if err != nil {
status = Off
}
if status == Off && b.launch.firewallIsUp() {
return Failed, nil
}
return status, nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment