diff options
| author | Shulhan <ms@kilabit.info> | 2022-05-29 00:50:05 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-06-09 23:50:27 +0700 |
| commit | b4e49485f815db682def487191c129f8904d85eb (patch) | |
| tree | 6b790b2e65b493682b0e10253fc028e4fce6c6c1 | |
| parent | 5c354863c9c6fcc080f2407e6f7adea41fa4371d (diff) | |
| download | rescached-b4e49485f815db682def487191c129f8904d85eb.tar.xz | |
go.mod: update to share module v0.38.0
This changes affect the dns Server where all caches related methods has
been moved to field Caches.
| -rw-r--r-- | go.mod | 2 | ||||
| -rw-r--r-- | go.sum | 12 | ||||
| -rw-r--r-- | httpd.go | 24 | ||||
| -rw-r--r-- | rescached.go | 12 |
4 files changed, 27 insertions, 23 deletions
@@ -7,7 +7,7 @@ go 1.16 require ( git.sr.ht/~shulhan/ciigo v0.8.1 - github.com/shuLhan/share v0.37.1-0.20220517151646-345ee16b214a + github.com/shuLhan/share v0.38.0 ) //replace github.com/shuLhan/share => ../share @@ -4,20 +4,24 @@ git.sr.ht/~shulhan/ciigo v0.8.1 h1:d1iShGX3ArVwtPZJUlpSgcgS+PMlwLjfLmOrsmECbII= git.sr.ht/~shulhan/ciigo v0.8.1/go.mod h1:pOmpgVSLjkmhAEqJciX/Vd80CCoVd/kIl4ipTMI5vkc= github.com/shuLhan/share v0.35.0/go.mod h1:laKGR1DNboj8+INRIC9VFYRiVEu/IIjrLurUmTHXkw0= github.com/shuLhan/share v0.37.0/go.mod h1:laKGR1DNboj8+INRIC9VFYRiVEu/IIjrLurUmTHXkw0= -github.com/shuLhan/share v0.37.1-0.20220517151646-345ee16b214a h1:ObIeMvsFoBxPX+ejNUVl/w8ziKfr9cbAB8ELN3FnlTI= -github.com/shuLhan/share v0.37.1-0.20220517151646-345ee16b214a/go.mod h1:laKGR1DNboj8+INRIC9VFYRiVEu/IIjrLurUmTHXkw0= +github.com/shuLhan/share v0.38.0 h1:Da9aheUJxOQnrN9qwcC5KSrJt7yJUNXuOiY/KJ5Ekt0= +github.com/shuLhan/share v0.38.0/go.mod h1:1phZr6PX+8YLCOeNvx92J14/AV0mTo0Ebbc1SmzzYvk= golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a h1:ppl5mZgokTT8uPkmYOyEUmPTr3ypaKkg5eFOGrAmxxE= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -498,7 +498,7 @@ func (srv *Server) httpApiBlockdFetch(epr *libhttp.EndpointRequest) (resBody []b func (srv *Server) httpApiCaches(epr *libhttp.EndpointRequest) (resBody []byte, err error) { var ( res = libhttp.EndpointResponse{} - answers = srv.dns.CachesLRU() + answers = srv.dns.Caches.ExternalLRU() ) res.Code = http.StatusOK if len(answers) == 0 { @@ -531,7 +531,7 @@ func (srv *Server) httpApiCachesSearch(epr *libhttp.EndpointRequest) (resBody [] return nil, &res } - listMsg = srv.dns.SearchCaches(re) + listMsg = srv.dns.Caches.ExternalSearch(re) if listMsg == nil { listMsg = make([]*dns.Message, 0) } @@ -556,9 +556,9 @@ func (srv *Server) httpApiCachesDelete(epr *libhttp.EndpointRequest) (resBody [] return nil, &res } if q == "all" { - answers = srv.dns.CachesClear() + answers = srv.dns.Caches.ExternalClear() } else { - answers = srv.dns.RemoveCachesByNames([]string{q}) + answers = srv.dns.Caches.ExternalRemoveNames([]string{q}) } res.Code = http.StatusOK @@ -751,7 +751,7 @@ func (srv *Server) blockdEnable(hb *Blockd) (err error) { return fmt.Errorf("%s: %w", logp, err) } - err = srv.dns.PopulateCachesByRR(hfile.Records, hfile.Path) + err = srv.dns.Caches.InternalPopulateRecords(hfile.Records, hfile.Path) if err != nil { return fmt.Errorf("%s: %w", logp, err) } @@ -773,7 +773,7 @@ func (srv *Server) blockdDisable(hb *Blockd) (err error) { return fmt.Errorf("%s: unknown hosts block: %q", logp, hb.Name) } - srv.dns.RemoveLocalCachesByNames(hfile.Names()) + srv.dns.Caches.InternalRemoveNames(hfile.Names()) err = hb.disable() if err != nil { @@ -885,7 +885,7 @@ func (srv *Server) apiHostsdDelete(epr *libhttp.EndpointRequest) (resbody []byte } // Remove the records associated with hosts file. - srv.dns.RemoveLocalCachesByNames(hfile.Names()) + srv.dns.Caches.InternalRemoveNames(hfile.Names()) err = hfile.Delete() if err != nil { @@ -1013,7 +1013,7 @@ func (srv *Server) apiHostsdRecordAdd(epr *libhttp.EndpointRequest) (resbody []b return nil, &res } - err = srv.dns.PopulateCachesByRR([]*dns.ResourceRecord{rr}, hostsFileName) + err = srv.dns.Caches.InternalPopulateRecords([]*dns.ResourceRecord{rr}, hostsFileName) if err != nil { res.Code = http.StatusInternalServerError res.Message = err.Error() @@ -1076,7 +1076,7 @@ func (srv *Server) apiHostsdRecordDelete(epr *libhttp.EndpointRequest) (resbody return nil, &res } - srv.dns.RemoveLocalCachesByNames([]string{domainName}) + srv.dns.Caches.InternalRemoveNames([]string{domainName}) res.Code = http.StatusOK res.Message = "domain name '" + domainName + "' has been removed from hosts file" @@ -1190,7 +1190,7 @@ func (srv *Server) apiZonedDelete(epr *libhttp.EndpointRequest) (resb []byte, er names = append(names, name) } - srv.dns.RemoveLocalCachesByNames(names) + srv.dns.Caches.InternalRemoveNames(names) delete(srv.env.Zones, zoneName) err = zone.Delete() @@ -1365,7 +1365,7 @@ func (srv *Server) apiZonedRRAdd(epr *libhttp.EndpointRequest) (resb []byte, err } listRR = []*dns.ResourceRecord{rr} - err = srv.dns.PopulateCachesByRR(listRR, zoneFile.Path) + err = srv.dns.Caches.InternalPopulateRecords(listRR, zoneFile.Path) if err != nil { res.Code = http.StatusBadRequest res.Message = "PopulateCacheByRR: " + err.Error() @@ -1485,7 +1485,7 @@ func (srv *Server) apiZonedRRDelete(epr *libhttp.EndpointRequest) (resbody []byt } // Remove the RR from caches. - rr, err = srv.dns.RemoveCachesByRR(rr) + rr, err = srv.dns.Caches.InternalRemoveRecord(rr) if err != nil { res.Message = err.Error() return nil, &res diff --git a/rescached.go b/rescached.go index f8caf05..2c1b0ce 100644 --- a/rescached.go +++ b/rescached.go @@ -77,7 +77,7 @@ func (srv *Server) Start() (err error) { fcaches, err = os.Open(srv.env.pathFileCaches) if err == nil { // Load stored caches from file. - answers, err = srv.dns.CachesLoad(fcaches) + answers, err = srv.dns.Caches.ExternalLoad(fcaches) if err != nil { log.Printf("%s: %s", logp, err) } else { @@ -94,7 +94,7 @@ func (srv *Server) Start() (err error) { if err != nil { return err } - err = srv.dns.PopulateCachesByRR(hfile.Records, hfile.Path) + err = srv.dns.Caches.InternalPopulateRecords(hfile.Records, hfile.Path) if err != nil { return err } @@ -109,7 +109,7 @@ func (srv *Server) Start() (err error) { return fmt.Errorf("%s: %w", logp, err) } - err = srv.dns.PopulateCachesByRR(hfile.Records, hfile.Path) + err = srv.dns.Caches.InternalPopulateRecords(hfile.Records, hfile.Path) if err != nil { return fmt.Errorf("%s: %w", logp, err) } @@ -130,7 +130,7 @@ func (srv *Server) Start() (err error) { } for _, hfile = range srv.env.HostsFiles { - err = srv.dns.PopulateCachesByRR(hfile.Records, hfile.Path) + err = srv.dns.Caches.InternalPopulateRecords(hfile.Records, hfile.Path) if err != nil { return err } @@ -148,7 +148,7 @@ func (srv *Server) Start() (err error) { err = nil } for _, zone = range srv.env.Zones { - srv.dns.PopulateCaches(zone.Messages(), zone.Path) + srv.dns.Caches.InternalPopulate(zone.Messages(), zone.Path) } if len(srv.env.FileResolvConf) > 0 { @@ -205,7 +205,7 @@ func (srv *Server) Stop() { log.Printf("%s: %s", logp, err) return } - n, err = srv.dns.CachesSave(fcaches) + n, err = srv.dns.Caches.ExternalSave(fcaches) if err != nil { log.Printf("%s: %s", logp, err) // fall-through for Close. |
