mirror of
https://github.com/safing/portmaster
synced 2025-09-02 10:39:22 +00:00
Update based on portbase review suggestions
This commit is contained in:
parent
72c7592cdd
commit
60ac9af5f2
4 changed files with 12 additions and 12 deletions
|
@ -11,7 +11,7 @@ func registerActions() error {
|
||||||
if err := api.RegisterEndpoint(api.Endpoint{
|
if err := api.RegisterEndpoint(api.Endpoint{
|
||||||
Path: "core/shutdown",
|
Path: "core/shutdown",
|
||||||
Read: api.PermitSelf,
|
Read: api.PermitSelf,
|
||||||
ActionFn: shutdown,
|
ActionFunc: shutdown,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func registerActions() error {
|
||||||
if err := api.RegisterEndpoint(api.Endpoint{
|
if err := api.RegisterEndpoint(api.Endpoint{
|
||||||
Path: "core/restart",
|
Path: "core/restart",
|
||||||
Read: api.PermitSelf,
|
Read: api.PermitSelf,
|
||||||
ActionFn: restart,
|
ActionFunc: restart,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func startAPIAuth() {
|
||||||
log.Tracef("filter: api port set to %d", apiPort)
|
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() {
|
if devMode() {
|
||||||
return &api.AuthToken{
|
return &api.AuthToken{
|
||||||
Read: api.PermitSelf,
|
Read: api.PermitSelf,
|
||||||
|
@ -85,7 +85,7 @@ func apiAuthenticator(ctx context.Context, s *http.Server, r *http.Request) (tok
|
||||||
var retry bool
|
var retry bool
|
||||||
for tries := 0; tries < 20; tries++ {
|
for tries := 0; tries < 20; tries++ {
|
||||||
retry, err = authenticateAPIRequest(
|
retry, err = authenticateAPIRequest(
|
||||||
ctx,
|
r.Context(),
|
||||||
&packet.Info{
|
&packet.Info{
|
||||||
Inbound: false, // outbound as we are looking for the process of the source address
|
Inbound: false, // outbound as we are looking for the process of the source address
|
||||||
Version: packet.IPv4,
|
Version: packet.IPv4,
|
||||||
|
|
|
@ -82,7 +82,7 @@ func start() error {
|
||||||
if err := api.RegisterEndpoint(api.Endpoint{
|
if err := api.RegisterEndpoint(api.Endpoint{
|
||||||
Path: "dns/clear/namecache",
|
Path: "dns/clear/namecache",
|
||||||
Read: api.PermitUser,
|
Read: api.PermitUser,
|
||||||
ActionFn: clearNameCache,
|
ActionFunc: clearNameCache,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (rec *NameRecord) Save() error {
|
||||||
func clearNameCache(ar *api.Request) (msg string, err error) {
|
func clearNameCache(ar *api.Request) (msg string, err error) {
|
||||||
log.Warning("resolver: user requested dns cache clearing via action")
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue