From 60ac9af5f277de3fee2d1ec0886e191b30ae30a8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Jan 2021 13:35:25 +0100 Subject: [PATCH] Update based on portbase review suggestions --- core/api.go | 12 ++++++------ firewall/api.go | 4 ++-- resolver/main.go | 6 +++--- resolver/namerecord.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/api.go b/core/api.go index 8029f638..f61f9768 100644 --- a/core/api.go +++ b/core/api.go @@ -9,17 +9,17 @@ import ( func registerActions() error { if err := api.RegisterEndpoint(api.Endpoint{ - Path: "core/shutdown", - Read: api.PermitSelf, - ActionFn: shutdown, + Path: "core/shutdown", + Read: api.PermitSelf, + ActionFunc: shutdown, }); err != nil { return err } if err := api.RegisterEndpoint(api.Endpoint{ - Path: "core/restart", - Read: api.PermitSelf, - ActionFn: restart, + Path: "core/restart", + Read: api.PermitSelf, + ActionFunc: restart, }); err != nil { return err } diff --git a/firewall/api.go b/firewall/api.go index 88c1307c..267ad5a5 100644 --- a/firewall/api.go +++ b/firewall/api.go @@ -59,7 +59,7 @@ func startAPIAuth() { log.Tracef("filter: api port set to %d", apiPort) } -func apiAuthenticator(ctx context.Context, s *http.Server, r *http.Request) (token *api.AuthToken, err error) { +func apiAuthenticator(r *http.Request, s *http.Server) (token *api.AuthToken, err error) { if devMode() { return &api.AuthToken{ Read: api.PermitSelf, @@ -85,7 +85,7 @@ func apiAuthenticator(ctx context.Context, s *http.Server, r *http.Request) (tok var retry bool for tries := 0; tries < 20; tries++ { retry, err = authenticateAPIRequest( - ctx, + r.Context(), &packet.Info{ Inbound: false, // outbound as we are looking for the process of the source address Version: packet.IPv4, diff --git a/resolver/main.go b/resolver/main.go index 543e4465..343d5a50 100644 --- a/resolver/main.go +++ b/resolver/main.go @@ -80,9 +80,9 @@ func start() error { // Register api endpoint to clear DNS cache. if err := api.RegisterEndpoint(api.Endpoint{ - Path: "dns/clear/namecache", - Read: api.PermitUser, - ActionFn: clearNameCache, + Path: "dns/clear/namecache", + Read: api.PermitUser, + ActionFunc: clearNameCache, }); err != nil { return err } diff --git a/resolver/namerecord.go b/resolver/namerecord.go index 15ca2902..6c04d7be 100644 --- a/resolver/namerecord.go +++ b/resolver/namerecord.go @@ -109,7 +109,7 @@ func (rec *NameRecord) Save() error { func clearNameCache(ar *api.Request) (msg string, err error) { log.Warning("resolver: user requested dns cache clearing via action") - n, err := recordDatabase.Purge(ar.Ctx(), query.New(nameRecordsKeyPrefix)) + n, err := recordDatabase.Purge(ar.Context(), query.New(nameRecordsKeyPrefix)) if err != nil { return "", err }