s/weaveIP/ip

This commit is contained in:
Matthias Radestock committed 2014-11-27 16:31:42 +00:00
1 parent 24702e3a7a
commit 56bfb09656
5 files changed
+47 -47

No files matched your search

+14 -14
View File
@@ -45,22 +45,22 @@ func ListenHttp(domain string, db Zone, port int) {
switch r.Method {
case "PUT":
ident, weaveIPstr, err := parseUrl(r.URL.Path)
ident, ipStr, err := parseUrl(r.URL.Path)
name := r.FormValue("fqdn")
if ident == "" || weaveIPstr == "" || name == "" {
if ident == "" || ipStr == "" || name == "" {
reqError("Invalid request", "Invalid request: %s, %s", r.URL, r.Form)
return
}
weaveIP := net.ParseIP(weaveIPstr)
if weaveIP == nil {
reqError("Invalid weave IP", "Invalid weave IP in request: %s", weaveIPstr)
ip := net.ParseIP(ipStr)
if ip == nil {
reqError("Invalid IP", "Invalid IP in request: %s", ipStr)
return
}
if dns.IsSubDomain(domain, name) {
Info.Printf("Adding %s -> %s", name, weaveIPstr)
if err = db.AddRecord(ident, name, weaveIP); err != nil {
Info.Printf("Adding %s -> %s", name, ipStr)
if err = db.AddRecord(ident, name, ip); err != nil {
if dup, ok := err.(DuplicateError); !ok {
httpErrorAndLog(
Error, w, "Internal error", http.StatusInternalServerError,
@@ -76,19 +76,19 @@ func ListenHttp(domain string, db Zone, port int) {
}
case "DELETE":
ident, weaveIPstr, err := parseUrl(r.URL.Path)
if ident == "" || weaveIPstr == "" {
ident, ipStr, err := parseUrl(r.URL.Path)
if ident == "" || ipStr == "" {
reqError("Invalid Request", "Invalid request: %s, %s", r.URL, r.Form)
return
}
weaveIP := net.ParseIP(weaveIPstr)
if weaveIP == nil {
reqError("Invalid IP in request", "Invalid IP in request: %s", weaveIPstr)
ip := net.ParseIP(ipStr)
if ip == nil {
reqError("Invalid IP in request", "Invalid IP in request: %s", ipStr)
return
}
Info.Printf("Deleting %s (%s)", ident, weaveIPstr)
if err = db.DeleteRecord(ident, weaveIP); err != nil {
Info.Printf("Deleting %s (%s)", ident, ipStr)
if err = db.DeleteRecord(ident, ip); err != nil {
if _, ok := err.(LookupError); !ok {
httpErrorAndLog(
Error, w, "Internal error", http.StatusInternalServerError,