summaryrefslogtreecommitdiff
path: root/pkg/helper/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/helper/helper.go')
-rw-r--r--pkg/helper/helper.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/helper/helper.go b/pkg/helper/helper.go
index 006d23b..d23cefd 100644
--- a/pkg/helper/helper.go
+++ b/pkg/helper/helper.go
@@ -24,6 +24,7 @@ package helper
import (
"encoding/json"
"log"
+ "net"
"net/http"
"os/exec"
)
@@ -128,6 +129,12 @@ func firewallStartHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ for _, gw := range gateways {
+ if !validAddress(gw) {
+ w.Write([]byte("bad argument"))
+ }
+ }
+
err = firewallStart(gateways)
if err != nil {
log.Printf("Error starting firewall: %v", err)
@@ -167,3 +174,11 @@ func getArgs(r *http.Request) ([]string, error) {
err := decoder.Decode(&args)
return args, err
}
+
+func validAddress(ip string) bool {
+ if net.ParseIP(ip) == nil {
+ return false
+ } else {
+ return true
+ }
+}