diff --git a/.dockerignore b/.dockerignore index 7471db553..114be4698 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ bin/ .idea .github -testdata/ \ No newline at end of file +testdata/ +node_modules/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 339a8d777..da1f21265 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ config.yml coverage.txt todo.txt !docs/config.yml +node_modules diff --git a/Makefile b/Makefile index 7436fd25c..53828e400 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all tools clean build test lint run buildMultiArchRelease help +.PHONY: all tools clean build swagger test lint run buildMultiArchRelease help .DEFAULT_GOAL := help VERSION := $(shell git describe --always --tags) @@ -16,8 +16,13 @@ all: test lint build ## Build binary (with tests) clean: ## cleans output directory $(shell rm -rf $(BIN_OUT_DIR)/*) -build: ## Build binary +swagger: + npm install bootprint bootprint-openapi html-inline $(shell go env GOPATH)/bin/swag init -g api/api.go + $(shell) node_modules/bootprint/bin/bootprint.js openapi docs/swagger.json /tmp/swagger/ + $(shell) node_modules/html-inline/bin/cmd.js /tmp/swagger/index.html > docs/swagger.html + +build: ## Build binary go build -v -ldflags="-w -s -X blocky/cmd.version=${VERSION} -X blocky/cmd.buildTime=${BUILD_TIME}" -o $(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX) test: ## run tests diff --git a/docs/swagger.html b/docs/swagger.html new file mode 100644 index 000000000..87e006824 --- /dev/null +++ b/docs/swagger.html @@ -0,0 +1,8540 @@ + + +
+ + ++ Base URL: /api/, + Version: +
++
blocky API
+ + + ++
+Operation | +Description | +
---|---|
GET /blocking/disable | +Disable blocking + |
+
GET /blocking/enable | +Enable blocking + |
+
GET /blocking/status | +Blocking status + |
+
+
+Operation | +Description | +
---|---|
POST /query | +Performs DNS query + |
+
disable the blocking status
+ ++ | + | + | + | + |
---|---|---|---|---|
+ duration + | +duration of blocking (Example: 300s, 5m, 1h, 5m30s) + |
+ query | ++ string (duration) + + + | ++ | +
Blocking is disabled
+ +Wrong duration format
+ +enable the blocking status
+ +Blocking is enabled
+ +get current blocking status
+ +application/json +
+ +Returns current blocking status
+ +Performs DNS query
+ +application/json +
++
query data
+ +application/json +
+ +query was executed
+ +Wrong request format
+ +If blocking is temporary disabled: amount of seconds until blocking will be enabled
+ +True if blocking is enabled
+ +query for DNS request
+ +request type (A, AAAA, ...)
+ +blocky reason for resolution
+ +actual DNS response
+ +response type (CACHED, BLOCKED, ...)
+ +DNS return code (NOERROR, NXDOMAIN, ...)
+ +