aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-05-13 21:14:29 +0700
committerShulhan <ms@kilabit.info>2022-05-13 21:14:29 +0700
commit20c3f80e7dfd9e453d757199beb2137c09a9f536 (patch)
tree82711df23adee40b578a4da395a9588877132d88 /httpd.go
parentc9de13ce2432dee7d58fb45c4cecbf026786a48d (diff)
downloadrescached-20c3f80e7dfd9e453d757199beb2137c09a9f536.tar.xz
cmd/resolver: implement command to delete record on hosts file
The command has the following signature, resolver hosts.d rr delete <name> <domain> Given the hosts name "hosts" and domain "my.hosts" it will delete all records that have domain name "my.hosts" inside the file.
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/httpd.go b/httpd.go
index e336307..4ae5a60 100644
--- a/httpd.go
+++ b/httpd.go
@@ -915,6 +915,7 @@ func (srv *Server) apiHostsdRecordDelete(epr *libhttp.EndpointRequest) (resbody
domainName = epr.HttpRequest.Form.Get(paramNameDomain)
hfile *dns.HostsFile
+ rr *dns.ResourceRecord
found bool
)
@@ -935,8 +936,8 @@ func (srv *Server) apiHostsdRecordDelete(epr *libhttp.EndpointRequest) (resbody
return nil, &res
}
- found = hfile.RemoveRecord(domainName)
- if !found {
+ rr = hfile.RemoveRecord(domainName)
+ if rr == nil {
res.Message = "unknown domain name: " + domainName
return nil, &res
}
@@ -951,6 +952,7 @@ func (srv *Server) apiHostsdRecordDelete(epr *libhttp.EndpointRequest) (resbody
res.Code = http.StatusOK
res.Message = "domain name '" + domainName + "' has been removed from hosts file"
+ res.Data = rr
return json.Marshal(&res)
}