forked from 0xERR0R/blocky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
60 lines (48 loc) · 1.76 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// @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/
// Package api provides basic API structs for the REST services
package api
const (
// PathBlockingStatusPath defines the REST endpoint for blocking status
PathBlockingStatusPath = "/api/blocking/status"
// PathBlockingEnablePath defines the REST endpoint for blocking enable
PathBlockingEnablePath = "/api/blocking/enable"
// PathBlockingDisablePath defines the REST endpoint for blocking disable
PathBlockingDisablePath = "/api/blocking/disable"
// PathListsRefresh defines the REST endpoint for blocking refresh
PathListsRefresh = "/api/lists/refresh"
// PathQueryPath defines the REST endpoint for query
PathQueryPath = "/api/query"
)
// QueryRequest is a data structure for a DNS request
type QueryRequest struct {
// query for DNS request
Query string
// request type (A, AAAA, ...)
Type string
}
// QueryResult is a data structure for the DNS result
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"`
}
// BlockingStatus represents the current blocking status
type BlockingStatus struct {
// True if blocking is enabled
Enabled bool `json:"enabled"`
// Disabled group names
DisabledGroups []string `json:"disabledGroups"`
// If blocking is temporary disabled: amount of seconds until blocking will be enabled
AutoEnableInSec uint `json:"autoEnableInSec"`
}