aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-05-22 21:56:02 +0700
committerShulhan <ms@kilabit.info>2022-05-22 21:56:02 +0700
commitfdb3c4462417dd1caeb28d263c1f3be6e453f6bb (patch)
tree3d02ae3790786b14403b872150ce4f2790c59dcf /client.go
parente62bf6a1a77f87487ad1fbeae5f30730d441cda4 (diff)
downloadrescached-fdb3c4462417dd1caeb28d263c1f3be6e453f6bb.tar.xz
all: use the exported Blockd type instead of interface{}
Since we have exported the Blockd type from rescached package, any Blockd operation on the HTTP server and on the client on cmd/resolver can use it instead of using interface{}.
Diffstat (limited to 'client.go')
-rw-r--r--client.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/client.go b/client.go
index 480fe53..18a5f7b 100644
--- a/client.go
+++ b/client.go
@@ -61,13 +61,12 @@ func (cl *Client) Blockd() (hostBlockd map[string]*Blockd, err error) {
}
// BlockdDisable disable specific hosts on block.d.
-func (cl *Client) BlockdDisable(blockdName string) (an interface{}, err error) {
+func (cl *Client) BlockdDisable(blockdName string) (blockd *Blockd, err error) {
var (
logp = "BlockdDisable"
res = libhttp.EndpointResponse{}
params = url.Values{}
- hb *Blockd
resb []byte
)
@@ -78,7 +77,7 @@ func (cl *Client) BlockdDisable(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %w", logp, err)
}
- res.Data = &hb
+ res.Data = &blockd
err = json.Unmarshal(resb, &res)
if err != nil {
return nil, fmt.Errorf("%s: %w", logp, err)
@@ -87,17 +86,16 @@ func (cl *Client) BlockdDisable(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %d %s", logp, res.Code, res.Message)
}
- return hb, nil
+ return blockd, nil
}
// BlockdEnable enable specific hosts on block.d.
-func (cl *Client) BlockdEnable(blockdName string) (an interface{}, err error) {
+func (cl *Client) BlockdEnable(blockdName string) (blockd *Blockd, err error) {
var (
logp = "BlockdEnable"
res = libhttp.EndpointResponse{}
params = url.Values{}
- hb *Blockd
resb []byte
)
@@ -108,7 +106,7 @@ func (cl *Client) BlockdEnable(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %w", logp, err)
}
- res.Data = &hb
+ res.Data = &blockd
err = json.Unmarshal(resb, &res)
if err != nil {
return nil, fmt.Errorf("%s: %w", logp, err)
@@ -117,18 +115,17 @@ func (cl *Client) BlockdEnable(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %d %s", logp, res.Code, res.Message)
}
- return hb, nil
+ return blockd, nil
}
// BlockdUpdate fetch the latest hosts file from the hosts block
// provider based on registered URL.
-func (cl *Client) BlockdUpdate(blockdName string) (an interface{}, err error) {
+func (cl *Client) BlockdUpdate(blockdName string) (blockd *Blockd, err error) {
var (
logp = "BlockdUpdate"
params = url.Values{}
res = libhttp.EndpointResponse{}
- hb *Blockd
resb []byte
)
@@ -139,7 +136,7 @@ func (cl *Client) BlockdUpdate(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %w", logp, err)
}
- res.Data = &hb
+ res.Data = &blockd
err = json.Unmarshal(resb, &res)
if err != nil {
return nil, fmt.Errorf("%s: %w", logp, err)
@@ -148,7 +145,7 @@ func (cl *Client) BlockdUpdate(blockdName string) (an interface{}, err error) {
return nil, fmt.Errorf("%s: %d %s", logp, res.Code, res.Message)
}
- return hb, nil
+ return blockd, nil
}
// Caches fetch all of non-local caches from server.