summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-11-30 17:37:49 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-11-30 21:22:42 +0100
commit444f55c8f5e98c5d100e4e612473778648c334e2 (patch)
treea644d17b3d31f62b407c777021aff4878204af60 /pkg
parentc28d30f11eba58fd5e01f7f5b2cbccac9aa7b5bd (diff)
[bug] validate ips
Diffstat (limited to 'pkg')
-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
+ }
+}