Skip to content

Commit

Permalink
DNS update with FQDN in domain field, main.go
Browse files Browse the repository at this point in the history
This pull requests removes the  "ZONE" string from the "hostname" or "domain" fields of the request, as this is used by AVM fritz!box routers to check if the update is actually executed, but would recursively lead to updates in the form of:

ZONE=example.com
request url:
https://ddns.example.com/v3/update?hostname=hostname.example.com&myip=<ipaddr>&password=<passwd>
Resulting entry in the zone file: hostname.example.com.example.com

Solves dstapp#63
  • Loading branch information
gmkey committed Feb 16, 2021
1 parent 5c39bf8 commit 2a645b1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rest-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ func DynUpdate(w http.ResponseWriter, r *http.Request) {

return sharedSecret
},
Domain: func(r *http.Request) string { return r.URL.Query().Get("hostname") },
Domain: func(r *http.Request) string {
confDomain := "." + appConfig.Domain
srcDomain := r.URL.Query().Get("hostname")
srcDomain = strings.Replace(srcDomain, confDomain, "", -1)
return srcDomain
},
}
response := BuildWebserviceResponseFromRequest(r, appConfig, extractor)

Expand Down Expand Up @@ -77,7 +82,12 @@ func Update(w http.ResponseWriter, r *http.Request) {
extractor := RequestDataExtractor{
Address: func(r *http.Request) string { return r.URL.Query().Get("addr") },
Secret: func(r *http.Request) string { return r.URL.Query().Get("secret") },
Domain: func(r *http.Request) string { return r.URL.Query().Get("domain") },
Domain: func(r *http.Request) string {
confDomain := "." + appConfig.Domain
srcDomain := r.URL.Query().Get("domain")
srcDomain = strings.Replace(srcDomain, confDomain, "", -1)
return srcDomain
},
}
response := BuildWebserviceResponseFromRequest(r, appConfig, extractor)

Expand Down

0 comments on commit 2a645b1

Please sign in to comment.