diff options
Diffstat (limited to 'helper/helper.go')
-rw-r--r-- | helper/helper.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/helper/helper.go b/helper/helper.go index 9d6d327..198e2c0 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -51,6 +51,7 @@ func serveHTTP() { http.HandleFunc("/openvpn/stop", openvpn.stop) http.HandleFunc("/firewall/start", firewallStartHandler) http.HandleFunc("/firewall/stop", firewallStopHandler) + http.HandleFunc("/firewall/isup", firewallIsUpHandler) log.Fatal(http.ListenAndServe(bindAddr, nil)) } @@ -138,6 +139,16 @@ func firewallStopHandler(w http.ResponseWriter, r *http.Request) { log.Println("Stop firewall: firewall stopped") } +func firewallIsUpHandler(w http.ResponseWriter, r *http.Request) { + if firewallIsUp() { + w.Write([]byte("true")) + w.WriteHeader(http.StatusOK) + } else { + w.Write([]byte("false")) + w.WriteHeader(http.StatusNoContent) + } +} + func getArgs(r *http.Request) ([]string, error) { args := []string{} decoder := json.NewDecoder(r.Body) |