updates to address comments by @bboreham

This commit is contained in:
Aaron Hurt committed 2018-08-31 14:26:00 -05:00
1 parent 4b9c533b94
commit c9f1d30f49
3 files changed
+5 -9

No files matched your search

+4 -5
View File
@@ -30,18 +30,17 @@ func (router *NetworkRouter) HandleHTTP(muxRouter *mux.Router) {
router.ForgetConnections(r.Form["peer"])
})
muxRouter.Methods("POST").Path("/expose/{ip}/{prefixlen}/{skipNAT}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
muxRouter.Methods("POST").Path("/expose/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
var skipNAT bool
cidr, err := address.ParseCIDR(vars["ip"] + "/" + vars["prefixlen"])
if err != nil {
http.Error(w, fmt.Sprint("unable to parse ip addr: ", err.Error()), http.StatusBadRequest)
return
}
if vars["skipNAT"] != "" {
skipNAT, err = strconv.ParseBool(vars["skipNAT"])
if err != nil {
var skipNAT bool
if r.FormValue("skipNAT") != "" {
if skipNAT, err = strconv.ParseBool(r.FormValue("skipNAT")); err != nil {
http.Error(w, fmt.Sprint("unable to parse skipNAT option: ", err.Error()), http.StatusBadRequest)
}
}