2020-04-08 23:03:07 +02:00
|
|
|
// @title blocky API
|
|
|
|
// @description blocky API
|
|
|
|
|
|
|
|
// @contact.name blocky@github
|
|
|
|
// @contact.url https://github.com/0xERR0R/blocky
|
|
|
|
|
|
|
|
// @license.name Apache 2.0
|
|
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
|
|
|
|
// @BasePath /api/
|
2021-02-26 13:45:57 +01:00
|
|
|
|
|
|
|
// Package api provides basic API structs for the REST services
|
2020-04-08 23:03:07 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
const (
|
2021-02-26 13:45:57 +01:00
|
|
|
// PathBlockingStatusPath defines the REST endpoint for blocking status
|
2021-02-26 21:39:41 +01:00
|
|
|
PathBlockingStatusPath = "/api/blocking/status"
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// PathBlockingEnablePath defines the REST endpoint for blocking enable
|
2021-02-26 21:39:41 +01:00
|
|
|
PathBlockingEnablePath = "/api/blocking/enable"
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// PathBlockingDisablePath defines the REST endpoint for blocking disable
|
2021-02-08 21:56:58 +01:00
|
|
|
PathBlockingDisablePath = "/api/blocking/disable"
|
2021-02-26 21:39:41 +01:00
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// PathListsRefresh defines the REST endpoint for blocking refresh
|
2021-02-26 21:39:41 +01:00
|
|
|
PathListsRefresh = "/api/lists/refresh"
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// PathQueryPath defines the REST endpoint for query
|
2021-02-26 21:39:41 +01:00
|
|
|
PathQueryPath = "/api/query"
|
2021-10-13 22:47:14 +02:00
|
|
|
|
|
|
|
// PathDohQuery DoH Url
|
|
|
|
PathDohQuery = "/dns-query"
|
2020-04-08 23:03:07 +02:00
|
|
|
)
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// QueryRequest is a data structure for a DNS request
|
2020-04-10 17:08:59 +02:00
|
|
|
type QueryRequest struct {
|
|
|
|
// query for DNS request
|
|
|
|
Query string
|
|
|
|
// request type (A, AAAA, ...)
|
|
|
|
Type string
|
|
|
|
}
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// QueryResult is a data structure for the DNS result
|
2020-04-10 17:08:59 +02:00
|
|
|
type QueryResult struct {
|
|
|
|
// blocky reason for resolution
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
// response type (CACHED, BLOCKED, ...)
|
|
|
|
ResponseType string `json:"responseType"`
|
|
|
|
// actual DNS response
|
|
|
|
Response string `json:"response"`
|
|
|
|
// DNS return code (NOERROR, NXDOMAIN, ...)
|
|
|
|
ReturnCode string `json:"returnCode"`
|
|
|
|
}
|
|
|
|
|
2021-02-26 13:45:57 +01:00
|
|
|
// BlockingStatus represents the current blocking status
|
2020-04-08 23:03:07 +02:00
|
|
|
type BlockingStatus struct {
|
|
|
|
// True if blocking is enabled
|
|
|
|
Enabled bool `json:"enabled"`
|
2021-04-28 22:38:23 +02:00
|
|
|
// Disabled group names
|
|
|
|
DisabledGroups []string `json:"disabledGroups"`
|
2020-04-08 23:03:07 +02:00
|
|
|
// If blocking is temporary disabled: amount of seconds until blocking will be enabled
|
|
|
|
AutoEnableInSec uint `json:"autoEnableInSec"`
|
|
|
|
}
|