Add api endpoint to query the DNS cache database including the memory cache
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
package resolver
|
package resolver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/safing/portbase/api"
|
"github.com/safing/portbase/api"
|
||||||
|
"github.com/safing/portbase/database/record"
|
||||||
)
|
)
|
||||||
|
|
||||||
func registerAPI() error {
|
func registerAPI() error {
|
||||||
@@ -25,6 +28,24 @@ func registerAPI() error {
|
|||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user