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

-3
View File
@@ -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
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)
}
}
+1 -1
View File
@@ -430,7 +430,7 @@ EOF
}
expose_ip() {
[ -z $WITHOUT_MASQUERADE ] || skipNAT="/true"
[ -z $WITHOUT_MASQUERADE ] || skipNAT="?skipNAT=true"
ipam_cidrs allocate_no_check_alive weave:expose $CIDR_ARGS
for CIDR in $ALL_CIDRS ; do
call_weave "POST" "/expose/$CIDR$skipNAT"