diff options
| author | Shulhan <ms@kilabit.info> | 2022-05-13 21:14:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-05-13 21:14:29 +0700 |
| commit | 20c3f80e7dfd9e453d757199beb2137c09a9f536 (patch) | |
| tree | 82711df23adee40b578a4da395a9588877132d88 /httpd.go | |
| parent | c9de13ce2432dee7d58fb45c4cecbf026786a48d (diff) | |
| download | rescached-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.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) } |
