updates to address comments by @bboreham
This commit is contained in:
1 parent
4b9c533b94
commit
c9f1d30f49
3 files changed
+5
-9
No files matched your search
@@ -36,9 +36,6 @@ coverage.html
|
||||
# Sed backup files
|
||||
*.bak
|
||||
|
||||
# JetBrains/GoLand/IntelliJ project file
|
||||
.idea
|
||||
|
||||
# Project specific
|
||||
prog/weaver/weaver
|
||||
prog/weavedns/weavedns
|
||||
|
||||
+4
-5
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user