mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Add api endpoint to query the DNS cache database including the memory cache
This commit is contained in:
parent
ccefcd6b3b
commit
317962be5d
1 changed files with 21 additions and 0 deletions
|
@ -1,7 +1,10 @@
|
|||
package resolver
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/safing/portbase/api"
|
||||
"github.com/safing/portbase/database/record"
|
||||
)
|
||||
|
||||
func registerAPI() error {
|
||||
|
@ -25,6 +28,24 @@ func registerAPI() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := api.RegisterEndpoint(api.Endpoint{
|
||||
Path: `dns/cache`,
|
||||
Read: api.PermitUser,
|
||||
RecordFunc: func(r *api.Request) (record.Record, error) {
|
||||
return recordDatabase.Get(nameRecordsKeyPrefix + r.URL.Query().Get("q"))
|
||||
},
|
||||
Name: "Get DNS Record from Cache",
|
||||
Description: "Returns cached dns records from the internal cache.",
|
||||
Parameters: []api.Parameter{{
|
||||
Method: http.MethodGet,
|
||||
Field: "q",
|
||||
Value: "fqdn and query type",
|
||||
Description: "Specify the query like this: `example.com.A`.",
|
||||
}},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue