Compare commits
184 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32c728ccf8 | ||
|
|
327d67c9ef | ||
|
|
edd7f82351 | ||
|
|
012d43b950 | ||
|
|
e2298f6f1e | ||
|
|
18350f94a6 | ||
|
|
1a9d5df5cb | ||
|
|
8ef1eb8c2a | ||
|
|
7c2018acbc | ||
|
|
2079f6a3eb | ||
|
|
d9419446bf | ||
|
|
c0cbccb63c | ||
|
|
5444dda08a | ||
|
|
224617aae6 | ||
|
|
c941c8a100 | ||
|
|
07a25cd094 | ||
|
|
54d98c10fe | ||
|
|
4a897c40b5 | ||
|
|
9af45d3cab | ||
|
|
9c60b399a8 | ||
|
|
01dbf8e50a | ||
|
|
58d0302c74 | ||
|
|
90ea6a13de | ||
|
|
4f80a7979f | ||
|
|
3812101c25 | ||
|
|
8c79c8b32d | ||
|
|
0afc437252 | ||
|
|
6ae53fea6e | ||
|
|
d925ccf45a | ||
|
|
24243a4b4d | ||
|
|
ef9ebc29b7 | ||
|
|
bd4e0f2b28 | ||
|
|
e952c9f85a | ||
|
|
df67e9a0bd | ||
|
|
7e47ed0879 | ||
|
|
1952ec1527 | ||
|
|
9ca5205d6a | ||
|
|
8a8da9d162 | ||
|
|
6440c71492 | ||
|
|
0b66b2debb | ||
|
|
351c142b91 | ||
|
|
8ce6aed66f | ||
|
|
778d18d816 | ||
|
|
2ea436bbbc | ||
|
|
b5a820b6f4 | ||
|
|
37f5043493 | ||
|
|
7638fb75a3 | ||
|
|
fdad6d3b7b | ||
|
|
074e300974 | ||
|
|
523e068195 | ||
|
|
9a7c617311 | ||
|
|
c214899b75 | ||
|
|
e31a8c8064 | ||
|
|
31cc27df1b | ||
|
|
d60051b5cb | ||
|
|
6770ae2a99 | ||
|
|
84738809ef | ||
|
|
43a08f7eef | ||
|
|
89aeec5f97 | ||
|
|
00ee5415a5 | ||
|
|
b5bd79b61e | ||
|
|
7080c236eb | ||
|
|
bb073eb51e | ||
|
|
7372d49aca | ||
|
|
1d771d4a0a | ||
|
|
dcffdbd98e | ||
|
|
abcc2e4125 | ||
|
|
e453381382 | ||
|
|
9a9913998a | ||
|
|
a3cdb66fe6 | ||
|
|
39aa84e2fd | ||
|
|
1ec2270eb5 | ||
|
|
5d1ee9b538 | ||
|
|
03d3cf57e9 | ||
|
|
2a5465ddb0 | ||
|
|
84efc786d4 | ||
|
|
12e5fb6f7f | ||
|
|
5c66900fdb | ||
|
|
2710ead089 | ||
|
|
839aa420e0 | ||
|
|
4ee42d4092 | ||
|
|
b2950f0718 | ||
|
|
7b1793476d | ||
|
|
f8750ef231 | ||
|
|
cc9283530f | ||
|
|
5a61e56766 | ||
|
|
8f71d514ee | ||
|
|
1b122b228f | ||
|
|
e88c0cdd38 | ||
|
|
3ceb188b81 | ||
|
|
0bc52ecb3c | ||
|
|
36d6c37df3 | ||
|
|
8fd793fdab | ||
|
|
be1909aedb | ||
|
|
e83b4d84ec | ||
|
|
b39b3f38fe | ||
|
|
d50765925b | ||
|
|
e0f8971155 | ||
|
|
f1d53f5610 | ||
|
|
4b4e6b1c72 | ||
|
|
095af716c9 | ||
|
|
e4e9f050df | ||
|
|
638b9b9428 | ||
|
|
0d4d18c595 | ||
|
|
33350c168d | ||
|
|
1bbb882225 | ||
|
|
6e86e8e5c5 | ||
|
|
7cb4c8793a | ||
|
|
4d2c636d9b | ||
|
|
9895d6de43 | ||
|
|
f62b6f94c5 | ||
|
|
e00d9a6c59 | ||
|
|
d2e573bbed | ||
|
|
8c0b6ee70d | ||
|
|
b9c7b1f559 | ||
|
|
7b5b876b0c | ||
|
|
848fb50132 | ||
|
|
6206402cae | ||
|
|
b24dc91ef2 | ||
|
|
d2d58f9058 | ||
|
|
e6fb75f715 | ||
|
|
3b31049636 | ||
|
|
5db091d800 | ||
|
|
8278ecb6a2 | ||
|
|
084eeba24a | ||
|
|
0134840300 | ||
|
|
05335aaf3f | ||
|
|
fb38741036 | ||
|
|
5a07feaffd | ||
|
|
e555c287bf | ||
|
|
ad52f32a3b | ||
|
|
665b27cfbe | ||
|
|
871d558ffd | ||
|
|
881e00e7e3 | ||
|
|
29963b9d75 | ||
|
|
bea8ec2d98 | ||
|
|
851f5fad58 | ||
|
|
1125837420 | ||
|
|
34f9a13da3 | ||
|
|
1432ab4b52 | ||
|
|
8f3a8e3572 | ||
|
|
87d5903cfc | ||
|
|
a50639af23 | ||
|
|
c4b1a70dac | ||
|
|
94677c7a39 | ||
|
|
cd2295ef05 | ||
|
|
944bb42074 | ||
|
|
1350364804 | ||
|
|
3625395d32 | ||
|
|
c32ed90a2e | ||
|
|
9af8c00bca | ||
|
|
0af476ac8e | ||
|
|
3b58e8ce3c | ||
|
|
1fffb80066 | ||
|
|
5f7e6e69e3 | ||
|
|
14e84b23d1 | ||
|
|
562576b8d4 | ||
|
|
532962527f | ||
|
|
99d1914542 | ||
|
|
6fa534dac1 | ||
|
|
3b6da33535 | ||
|
|
ded4a22a67 | ||
|
|
ab0589916f | ||
|
|
3226690d70 | ||
|
|
4d235491f2 | ||
|
|
96b7890404 | ||
|
|
760cc01217 | ||
|
|
c394a05fc1 | ||
|
|
11ab4483e0 | ||
|
|
65747a7f28 | ||
|
|
ca9ddc4222 | ||
|
|
6a2237b513 | ||
|
|
4afccfad8d | ||
|
|
9a32a1d638 | ||
|
|
e091914a06 | ||
|
|
7b584668ac | ||
|
|
30019327da | ||
|
|
fc8eeeaf0a | ||
|
|
11201881c0 | ||
|
|
498dcb8bcb | ||
|
|
5564239bea | ||
|
|
5319c5f53f | ||
|
|
49b9e1ce1f | ||
|
|
82a61aef09 |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
dist
|
||||
bin
|
||||
13
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
13
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@@ -17,7 +17,9 @@ body:
|
||||
id: adguardhome-sync-version
|
||||
attributes:
|
||||
label: AdguardHome-Sync Version
|
||||
description: What version of adguardhome-sync was running when you discovered this issue?
|
||||
description: |
|
||||
- What version of adguardhome-sync was running when you discovered this issue?
|
||||
- Are you running the docker or binary version?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -27,6 +29,15 @@ body:
|
||||
description: What version of adguardhome was running when you discovered this issue?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: os-information
|
||||
attributes:
|
||||
label: OS Information
|
||||
description: |
|
||||
- What Operating System are you running? `cat /etc/os-release`
|
||||
- What is the architecture of your CPU? `uname -m`
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: config
|
||||
attributes:
|
||||
|
||||
28
.github/dependabot.yml
vendored
28
.github/dependabot.yml
vendored
@@ -1,28 +0,0 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "gomod" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
groups:
|
||||
k8s:
|
||||
patterns:
|
||||
- "k8s.io/*"
|
||||
update-types:
|
||||
- "minor"
|
||||
- "patch"
|
||||
onsi:
|
||||
patterns:
|
||||
- "github.com/onsi/*"
|
||||
update-types:
|
||||
- "minor"
|
||||
- "patch"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@@ -20,6 +20,10 @@ on:
|
||||
schedule:
|
||||
- cron: '32 19 * * 6'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
name: docker-image
|
||||
name: docker-images
|
||||
|
||||
on:
|
||||
workflow_dispatch: # allows manual triggering
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
#pull_request:
|
||||
# branches:
|
||||
# - main
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
images:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -44,16 +51,16 @@ jobs:
|
||||
run: |
|
||||
sed -i -e "s|FROM scratch|FROM ${{ matrix.build.fromImage }}|g" Dockerfile
|
||||
|
||||
- name: Build and push ${{github.event.release.tag_name }}
|
||||
- name: Build images ${{github.event.release.tag_name }}
|
||||
id: docker_build_release
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
if: ${{ github.event.release.tag_name != '' }}
|
||||
with:
|
||||
context: .
|
||||
pull: true
|
||||
push: true
|
||||
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}latest,quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}${{ github.event.release.tag_name }},ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}latest,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}${{ github.event.release.tag_name }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/arm64,linux/ppc64le
|
||||
provenance: false
|
||||
build-args: |
|
||||
VERSION=${{ github.event.release.tag_name }}
|
||||
@@ -63,16 +70,16 @@ jobs:
|
||||
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV
|
||||
if: ${{ github.event.release.tag_name == '' }}
|
||||
|
||||
- name: Build and push main
|
||||
- name: Build images
|
||||
id: docker_build_main
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
if: ${{ github.event.release.tag_name == '' && env.NEW_COMMIT_COUNT > 0 }}
|
||||
with:
|
||||
context: .
|
||||
pull: true
|
||||
push: true
|
||||
push: ${{ github.ref == 'refs/heads/main' }}
|
||||
tags: quay.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main,ghcr.io/bakito/adguardhome-sync:${{ matrix.build.tagPrefix }}main
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/arm64,linux/ppc64le
|
||||
provenance: false
|
||||
build-args: |
|
||||
VERSION=main
|
||||
@@ -80,4 +87,3 @@ jobs:
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
||||
20
.github/workflows/e2e.yaml
vendored
20
.github/workflows/e2e.yaml
vendored
@@ -8,6 +8,10 @@ on:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -15,13 +19,15 @@ jobs:
|
||||
matrix:
|
||||
build:
|
||||
- mode: env
|
||||
protocol: https
|
||||
- mode: file
|
||||
protocol: http
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup jq
|
||||
uses: dcarbone/install-jq-action@v2
|
||||
uses: dcarbone/install-jq-action@v3
|
||||
|
||||
- name: Install kind with registry
|
||||
uses: bakito/kind-with-registry-action@main
|
||||
@@ -31,15 +37,19 @@ jobs:
|
||||
|
||||
- name: Install Helm Chart
|
||||
run: ./testdata/e2e/bin/install-chart.sh ${{ matrix.build.mode }}
|
||||
- name: Wait for pod to start
|
||||
run: ./testdata/e2e/bin/wait-for-start.sh ${{ matrix.build.protocol }}
|
||||
- name: Show origin pre Logs
|
||||
run: ./testdata/e2e/bin/show-origin-logs.sh pre
|
||||
- name: Wait for sync to finish
|
||||
run: ./testdata/e2e/bin/wait-for-sync.sh
|
||||
- name: Show origin Logs
|
||||
run: ./testdata/e2e/bin/show-origin-logs.sh
|
||||
run: ./testdata/e2e/bin/wait-for-sync.sh ${{ matrix.build.protocol }}
|
||||
- name: Show origin post Logs
|
||||
run: ./testdata/e2e/bin/show-origin-logs.sh post
|
||||
- name: Show Replica Logs
|
||||
run: ./testdata/e2e/bin/show-replica-logs.sh
|
||||
- name: Show Sync Logs
|
||||
run: ./testdata/e2e/bin/show-sync-logs.sh
|
||||
- name: Show Sync Metrics
|
||||
run: ./testdata/e2e/bin/show-sync-metrics.sh
|
||||
run: ./testdata/e2e/bin/show-sync-metrics.sh ${{ matrix.build.protocol }}
|
||||
- name: Read latest replica config
|
||||
run: ./testdata/e2e/bin/read-latest-replica-config.sh
|
||||
|
||||
16
.github/workflows/go.yml
vendored
16
.github/workflows/go.yml
vendored
@@ -6,6 +6,10 @@ on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
@@ -19,9 +23,9 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v4
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
skip-pkg-cache: true
|
||||
skip-cache: true
|
||||
|
||||
test:
|
||||
name: test
|
||||
@@ -36,6 +40,9 @@ jobs:
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
|
||||
- name: Model
|
||||
run: make model
|
||||
|
||||
- name: Test
|
||||
run: make test-ci
|
||||
|
||||
@@ -58,7 +65,4 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
with:
|
||||
version: latest
|
||||
args: --skip-publish --snapshot --rm-dist
|
||||
run: make test-release
|
||||
|
||||
16
.github/workflows/virustotal.yaml
vendored
Normal file
16
.github/workflows/virustotal.yaml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Scan GitHub Release with VirusTotal
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
scan_release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Analyze Build Assets
|
||||
uses: bakito/virustotal-action@main
|
||||
with:
|
||||
release_name: ${{github.event.release.tag_name}}
|
||||
vt_api_key: ${{secrets.VT_API_KEY}}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,7 +9,7 @@ main
|
||||
.adguardhome-sync.yaml
|
||||
tmp
|
||||
bin
|
||||
!testdata/e2e/bin
|
||||
config*.yaml
|
||||
*.log
|
||||
wiki
|
||||
Taskfile.yml
|
||||
|
||||
@@ -18,7 +18,6 @@ linters:
|
||||
- govet
|
||||
- importas
|
||||
- ineffassign
|
||||
- megacheck
|
||||
- misspell
|
||||
- nakedret
|
||||
- nolintlint
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
version: 2
|
||||
# This is an example goreleaser.yaml file with some sane defaults.
|
||||
# Make sure to check the documentation at http://goreleaser.com
|
||||
builds:
|
||||
@@ -34,12 +35,13 @@ builds:
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
version_template: "{{ .Tag }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
- '^chore'
|
||||
release:
|
||||
prerelease: auto
|
||||
|
||||
104
.toolbox.mk
Normal file
104
.toolbox.mk
Normal file
@@ -0,0 +1,104 @@
|
||||
## toolbox - start
|
||||
## Generated with https://github.com/bakito/toolbox
|
||||
|
||||
## Current working directory
|
||||
TB_LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd)
|
||||
## Location to install dependencies to
|
||||
TB_LOCALBIN ?= $(TB_LOCALDIR)/bin
|
||||
$(TB_LOCALBIN):
|
||||
mkdir -p $(TB_LOCALBIN)
|
||||
|
||||
## Tool Binaries
|
||||
TB_DEEPCOPY_GEN ?= $(TB_LOCALBIN)/deepcopy-gen
|
||||
TB_GINKGO ?= $(TB_LOCALBIN)/ginkgo
|
||||
TB_GOFUMPT ?= $(TB_LOCALBIN)/gofumpt
|
||||
TB_GOLANGCI_LINT ?= $(TB_LOCALBIN)/golangci-lint
|
||||
TB_GOLINES ?= $(TB_LOCALBIN)/golines
|
||||
TB_GORELEASER ?= $(TB_LOCALBIN)/goreleaser
|
||||
TB_MOCKGEN ?= $(TB_LOCALBIN)/mockgen
|
||||
TB_OAPI_CODEGEN ?= $(TB_LOCALBIN)/oapi-codegen
|
||||
TB_SEMVER ?= $(TB_LOCALBIN)/semver
|
||||
|
||||
## Tool Versions
|
||||
# renovate: packageName=k8s.io/code-generator/cmd/deepcopy-gen
|
||||
TB_DEEPCOPY_GEN_VERSION ?= v0.32.3
|
||||
# renovate: packageName=mvdan.cc/gofumpt
|
||||
TB_GOFUMPT_VERSION ?= v0.7.0
|
||||
# renovate: packageName=github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
TB_GOLANGCI_LINT_VERSION ?= v1.64.7
|
||||
# renovate: packageName=github.com/segmentio/golines
|
||||
TB_GOLINES_VERSION ?= v0.12.2
|
||||
# renovate: packageName=github.com/goreleaser/goreleaser/v2
|
||||
TB_GORELEASER_VERSION ?= v2.8.0
|
||||
# renovate: packageName=go.uber.org/mock/mockgen
|
||||
TB_MOCKGEN_VERSION ?= v0.5.0
|
||||
# renovate: packageName=github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
|
||||
TB_OAPI_CODEGEN_VERSION ?= v2.4.1
|
||||
# renovate: packageName=github.com/bakito/semver
|
||||
TB_SEMVER_VERSION ?= v1.1.3
|
||||
|
||||
## Tool Installer
|
||||
.PHONY: tb.deepcopy-gen
|
||||
tb.deepcopy-gen: $(TB_DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary.
|
||||
$(TB_DEEPCOPY_GEN): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/deepcopy-gen || GOBIN=$(TB_LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(TB_DEEPCOPY_GEN_VERSION)
|
||||
.PHONY: tb.ginkgo
|
||||
tb.ginkgo: $(TB_GINKGO) ## Download ginkgo locally if necessary.
|
||||
$(TB_GINKGO): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/ginkgo || GOBIN=$(TB_LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
.PHONY: tb.gofumpt
|
||||
tb.gofumpt: $(TB_GOFUMPT) ## Download gofumpt locally if necessary.
|
||||
$(TB_GOFUMPT): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/gofumpt || GOBIN=$(TB_LOCALBIN) go install mvdan.cc/gofumpt@$(TB_GOFUMPT_VERSION)
|
||||
.PHONY: tb.golangci-lint
|
||||
tb.golangci-lint: $(TB_GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
|
||||
$(TB_GOLANGCI_LINT): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/golangci-lint || GOBIN=$(TB_LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(TB_GOLANGCI_LINT_VERSION)
|
||||
.PHONY: tb.golines
|
||||
tb.golines: $(TB_GOLINES) ## Download golines locally if necessary.
|
||||
$(TB_GOLINES): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/golines || GOBIN=$(TB_LOCALBIN) go install github.com/segmentio/golines@$(TB_GOLINES_VERSION)
|
||||
.PHONY: tb.goreleaser
|
||||
tb.goreleaser: $(TB_GORELEASER) ## Download goreleaser locally if necessary.
|
||||
$(TB_GORELEASER): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/goreleaser || GOBIN=$(TB_LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(TB_GORELEASER_VERSION)
|
||||
.PHONY: tb.mockgen
|
||||
tb.mockgen: $(TB_MOCKGEN) ## Download mockgen locally if necessary.
|
||||
$(TB_MOCKGEN): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/mockgen || GOBIN=$(TB_LOCALBIN) go install go.uber.org/mock/mockgen@$(TB_MOCKGEN_VERSION)
|
||||
.PHONY: tb.oapi-codegen
|
||||
tb.oapi-codegen: $(TB_OAPI_CODEGEN) ## Download oapi-codegen locally if necessary.
|
||||
$(TB_OAPI_CODEGEN): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/oapi-codegen || GOBIN=$(TB_LOCALBIN) go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(TB_OAPI_CODEGEN_VERSION)
|
||||
.PHONY: tb.semver
|
||||
tb.semver: $(TB_SEMVER) ## Download semver locally if necessary.
|
||||
$(TB_SEMVER): $(TB_LOCALBIN)
|
||||
test -s $(TB_LOCALBIN)/semver || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/semver@$(TB_SEMVER_VERSION)
|
||||
|
||||
## Reset Tools
|
||||
.PHONY: tb.reset
|
||||
tb.reset:
|
||||
@rm -f \
|
||||
$(TB_LOCALBIN)/deepcopy-gen \
|
||||
$(TB_LOCALBIN)/ginkgo \
|
||||
$(TB_LOCALBIN)/gofumpt \
|
||||
$(TB_LOCALBIN)/golangci-lint \
|
||||
$(TB_LOCALBIN)/golines \
|
||||
$(TB_LOCALBIN)/goreleaser \
|
||||
$(TB_LOCALBIN)/mockgen \
|
||||
$(TB_LOCALBIN)/oapi-codegen \
|
||||
$(TB_LOCALBIN)/semver
|
||||
|
||||
## Update Tools
|
||||
.PHONY: tb.update
|
||||
tb.update: tb.reset
|
||||
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \
|
||||
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator \
|
||||
mvdan.cc/gofumpt@github.com/mvdan/gofumpt \
|
||||
github.com/golangci/golangci-lint/cmd/golangci-lint \
|
||||
github.com/segmentio/golines \
|
||||
github.com/goreleaser/goreleaser/v2 \
|
||||
go.uber.org/mock/mockgen@github.com/uber-go/mock \
|
||||
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen \
|
||||
github.com/bakito/semver
|
||||
## toolbox - end
|
||||
12
Dockerfile
12
Dockerfile
@@ -1,10 +1,8 @@
|
||||
FROM golang:1.22-bullseye as builder
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
WORKDIR /go/src/app
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y upx ca-certificates tzdata && \
|
||||
apt-get upgrade -y # upgrade to get latest ca-certs
|
||||
RUN apk update && apk add upx ca-certificates tzdata
|
||||
|
||||
ARG VERSION=main
|
||||
ARG BUILD="N/A"
|
||||
@@ -15,8 +13,10 @@ ENV GO111MODULE=on \
|
||||
|
||||
COPY . /go/src/app/
|
||||
|
||||
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/bakito/adguardhome-sync/version.Version=${VERSION} -X github.com/bakito/adguardhome-sync/version.Build=${BUILD}" -o adguardhome-sync . \
|
||||
&& upx -q adguardhome-sync
|
||||
|
||||
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/bakito/adguardhome-sync/version.Version=${VERSION} -X github.com/bakito/adguardhome-sync/version.Build=${BUILD}" -o adguardhome-sync .
|
||||
|
||||
RUN go version && upx -q adguardhome-sync
|
||||
|
||||
# application image
|
||||
FROM scratch
|
||||
|
||||
111
Makefile
111
Makefile
@@ -1,97 +1,45 @@
|
||||
# Include toolbox tasks
|
||||
include ./.toolbox.mk
|
||||
|
||||
# Run go lint against code
|
||||
lint: golangci-lint
|
||||
$(GOLANGCI_LINT) run --fix
|
||||
lint: tb.golangci-lint
|
||||
$(TB_GOLANGCI_LINT) run --fix
|
||||
|
||||
# Run go mod tidy
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
||||
generate: deepcopy-gen
|
||||
generate: tb.deepcopy-gen
|
||||
@mkdir -p ./tmp
|
||||
@touch ./tmp/deepcopy-gen-boilerplate.go.txt
|
||||
$(DEEPCOPY_GEN) -h ./tmp/deepcopy-gen-boilerplate.go.txt -i ./pkg/types
|
||||
$(TB_DEEPCOPY_GEN) --go-header-file ./tmp/deepcopy-gen-boilerplate.go.txt --bounding-dirs ./pkg/types
|
||||
|
||||
fmt: tb.golines tb.gofumpt
|
||||
$(TB_GOLINES) --base-formatter="$(TB_GOFUMPT)" --max-len=120 --write-output .
|
||||
|
||||
# Run tests
|
||||
test: generate lint test-ci
|
||||
test: generate fmt lint test-ci
|
||||
|
||||
fuzz:
|
||||
go test -fuzz=FuzzMask -v ./pkg/types/ -fuzztime=60s
|
||||
|
||||
# Run ci tests
|
||||
test-ci: mocks tidy ginkgo
|
||||
$(GINKGO) --cover --coverprofile coverage.out.tmp ./...
|
||||
test-ci: mocks tidy tb.ginkgo
|
||||
$(TB_GINKGO) --cover --coverprofile coverage.out.tmp ./...
|
||||
cat coverage.out.tmp | grep -v "_generated.go" > coverage.out
|
||||
go tool cover -func=coverage.out
|
||||
|
||||
mocks: mockgen
|
||||
$(MOCKGEN) -package client -destination pkg/mocks/client/mock.go github.com/bakito/adguardhome-sync/pkg/client Client
|
||||
$(MOCKGEN) -package client -destination pkg/mocks/flags/mock.go github.com/bakito/adguardhome-sync/pkg/config Flags
|
||||
mocks: tb.mockgen
|
||||
$(TB_MOCKGEN) -package client -destination pkg/mocks/client/mock.go github.com/bakito/adguardhome-sync/pkg/client Client
|
||||
$(TB_MOCKGEN) -package client -destination pkg/mocks/flags/mock.go github.com/bakito/adguardhome-sync/pkg/config Flags
|
||||
|
||||
release: semver goreleaser
|
||||
@version=$$($(LOCALBIN)/semver); \
|
||||
release: tb.semver tb.goreleaser
|
||||
@version=$$($(TB_SEMVER)); \
|
||||
git tag -s $$version -m"Release $$version"
|
||||
$(GORELEASER) --clean
|
||||
$(TB_GORELEASER) --clean
|
||||
|
||||
test-release: goreleaser
|
||||
$(GORELEASER) --skip=publish --snapshot --clean
|
||||
|
||||
## toolbox - start
|
||||
## Current working directory
|
||||
LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd)
|
||||
## Location to install dependencies to
|
||||
LOCALBIN ?= $(LOCALDIR)/bin
|
||||
$(LOCALBIN):
|
||||
mkdir -p $(LOCALBIN)
|
||||
|
||||
## Tool Binaries
|
||||
DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen
|
||||
GINKGO ?= $(LOCALBIN)/ginkgo
|
||||
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
|
||||
GORELEASER ?= $(LOCALBIN)/goreleaser
|
||||
MOCKGEN ?= $(LOCALBIN)/mockgen
|
||||
OAPI_CODEGEN ?= $(LOCALBIN)/oapi-codegen
|
||||
SEMVER ?= $(LOCALBIN)/semver
|
||||
|
||||
## Tool Installer
|
||||
.PHONY: deepcopy-gen
|
||||
deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary.
|
||||
$(DEEPCOPY_GEN): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen
|
||||
.PHONY: ginkgo
|
||||
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
|
||||
$(GINKGO): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
.PHONY: golangci-lint
|
||||
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
|
||||
$(GOLANGCI_LINT): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
.PHONY: goreleaser
|
||||
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
|
||||
$(GORELEASER): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser
|
||||
.PHONY: mockgen
|
||||
mockgen: $(MOCKGEN) ## Download mockgen locally if necessary.
|
||||
$(MOCKGEN): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install go.uber.org/mock/mockgen
|
||||
.PHONY: oapi-codegen
|
||||
oapi-codegen: $(OAPI_CODEGEN) ## Download oapi-codegen locally if necessary.
|
||||
$(OAPI_CODEGEN): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/oapi-codegen || GOBIN=$(LOCALBIN) go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen
|
||||
.PHONY: semver
|
||||
semver: $(SEMVER) ## Download semver locally if necessary.
|
||||
$(SEMVER): $(LOCALBIN)
|
||||
test -s $(LOCALBIN)/semver || GOBIN=$(LOCALBIN) go install github.com/bakito/semver
|
||||
|
||||
## Update Tools
|
||||
.PHONY: update-toolbox-tools
|
||||
update-toolbox-tools:
|
||||
@rm -f \
|
||||
$(LOCALBIN)/deepcopy-gen \
|
||||
$(LOCALBIN)/ginkgo \
|
||||
$(LOCALBIN)/golangci-lint \
|
||||
$(LOCALBIN)/goreleaser \
|
||||
$(LOCALBIN)/mockgen \
|
||||
$(LOCALBIN)/oapi-codegen \
|
||||
$(LOCALBIN)/semver
|
||||
toolbox makefile -f $(LOCALDIR)/Makefile
|
||||
## toolbox - end
|
||||
test-release: tb.goreleaser
|
||||
$(TB_GORELEASER) --skip=publish --snapshot --clean
|
||||
|
||||
start-replica:
|
||||
docker run --pull always --name adguardhome-replica -p 9091:3000 --rm adguard/adguardhome:latest
|
||||
@@ -122,12 +70,15 @@ kind-create:
|
||||
kind-test:
|
||||
@./testdata/e2e/bin/install-chart.sh
|
||||
|
||||
model: oapi-codegen
|
||||
# renovate: packageName=AdguardTeam/AdGuardHome
|
||||
ADGUARD_HOME_VERSION ?= v0.107.57
|
||||
|
||||
model: tb.oapi-codegen
|
||||
@mkdir -p tmp
|
||||
go run openapi/main.go v0.107.46
|
||||
$(OAPI_CODEGEN) -package model -generate types,client -config .oapi-codegen.yaml tmp/schema.yaml > pkg/client/model/model_generated.go
|
||||
go run openapi/main.go $(ADGUARD_HOME_VERSION)
|
||||
$(TB_OAPI_CODEGEN) -package model -generate types,client -config .oapi-codegen.yaml tmp/schema.yaml > pkg/client/model/model_generated.go
|
||||
|
||||
model-diff:
|
||||
go run openapi/main.go v0.107.46
|
||||
go run openapi/main.go $(ADGUARD_HOME_VERSION)
|
||||
go run openapi/main.go
|
||||
diff tmp/schema.yaml tmp/schema-master.yaml
|
||||
|
||||
115
README.md
115
README.md
@@ -22,6 +22,7 @@ and [Deprecations](https://github.com/bakito/adguardhome-sync/wiki/Deprecations)
|
||||
- Clients
|
||||
- DNS Config
|
||||
- DHCP Config
|
||||
- Theme
|
||||
|
||||
By default, all features are enabled. Single features can be disabled in the config.
|
||||
|
||||
@@ -71,9 +72,54 @@ export REPLICA1_PASSWORD=password
|
||||
adguardhome-sync run
|
||||
|
||||
# run as daemon
|
||||
adguardhome-sync run --cron "*/10 * * * *"
|
||||
adguardhome-sync run --cron "0 */2 * * *"
|
||||
```
|
||||
|
||||
### Run as Linux Service via Systemd
|
||||
|
||||
> Verified on Ubuntu Linux 24.04
|
||||
|
||||
Assume you have downloaded the the `adguardhome-sync` binary to `/opt/adguardhome-sync`.
|
||||
|
||||
Create systemd service file `/opt/adguardhome-sync/adguardhome-sync.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description = AdGuardHome Sync
|
||||
After = network.target
|
||||
|
||||
[Service]
|
||||
ExecStart = /opt/adguardhome-sync/adguardhome-sync --config /opt/adguardhome-sync/adguardhome-sync.yaml run
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
|
||||
```
|
||||
|
||||
Create a configuration file `/opt/adguardhome-sync/adguardhome-sync.yaml`, please follow [Config file](#config-file-1)
|
||||
section below for details.
|
||||
|
||||
Install and enable service:
|
||||
|
||||
```bash
|
||||
sudo cp /opt/adguardhome-sync/adguardhome-sync.service /etc/systemd/system/
|
||||
|
||||
sudo systemctl enable adguardhome-sync.service
|
||||
|
||||
sudo systemctl start adguardhome-sync.service
|
||||
|
||||
```
|
||||
|
||||
Then you can check the status:
|
||||
|
||||
```bash
|
||||
sudo systemctl status adguardhome-sync.service
|
||||
|
||||
```
|
||||
|
||||
If web UI has been enabled in configuration (default port is 8080), can also check the status via
|
||||
`http://<server-IP>:8080`
|
||||
|
||||
## Run Windows
|
||||
|
||||
```bash
|
||||
@@ -103,7 +149,7 @@ set FEATURES_DHCP_STATICLEASES=false
|
||||
adguardhome-sync run
|
||||
|
||||
# run as daemon
|
||||
adguardhome-sync run --cron "*/10 * * * *"
|
||||
adguardhome-sync run --cron "0 */2 * * *"
|
||||
```
|
||||
|
||||
## docker cli
|
||||
@@ -164,40 +210,53 @@ services:
|
||||
# REPLICA2_AUTO_SETUP: true # if true, AdGuardHome is automatically initialized.
|
||||
# REPLICA2_INTERFACE_NAME: 'ens18' # use custom dhcp interface name
|
||||
# REPLICA2_DHCP_SERVER_ENABLED: true/false (optional) enables/disables the dhcp server on the replica
|
||||
CRON: "*/10 * * * *" # run every 10 minutes
|
||||
RUNONSTART: true
|
||||
CRON: "0 */2 * * *" # run every 2 hours
|
||||
RUN_ON_START: "true"
|
||||
# CONTINUE_ON_ERROR: false # If enabled, the synchronisation task will not fail on single errors, but will log the errors and continue
|
||||
|
||||
# Configure the sync API server, disabled if api port is 0
|
||||
API_PORT: 8080
|
||||
# API_DARK_MODE: true
|
||||
# API_DARK_MODE: "true"
|
||||
# API_USERNAME: admin
|
||||
# API_PASSWORD: secret
|
||||
# the directory of the provided tls certs
|
||||
# API_TLS_CERT_DIR: /path/to/certs
|
||||
# the name of the cert file (default: tls.crt)
|
||||
# API_TLS_CERT_NAME: foo.crt
|
||||
# the name of the key file (default: tls.key)
|
||||
# API_TLS_KEY_NAME: bar.key
|
||||
# API_METRICS_ENABLED: "true"
|
||||
|
||||
# Configure sync features; by default all features are enabled.
|
||||
# FEATURES_GENERAL_SETTINGS: true
|
||||
# FEATURES_QUERY_LOG_CONFIG: true
|
||||
# FEATURES_STATS_CONFIG: true
|
||||
# FEATURES_CLIENT_SETTINGS: true
|
||||
# FEATURES_SERVICES: true
|
||||
# FEATURES_FILTERS: true
|
||||
# FEATURES_DHCP_SERVER_CONFIG: true
|
||||
# FEATURES_DHCP_STATIC_LEASES: true
|
||||
# FEATURES_DNS_SERVER_CONFIG: true
|
||||
# FEATURES_DNS_ACCESS_LISTS: true
|
||||
# FEATURES_DNS_REWRITES: true
|
||||
# FEATURES_GENERAL_SETTINGS: "true"
|
||||
# FEATURES_QUERY_LOG_CONFIG: "true"
|
||||
# FEATURES_STATS_CONFIG: "true"
|
||||
# FEATURES_CLIENT_SETTINGS: "true"
|
||||
# FEATURES_SERVICES: "true"
|
||||
# FEATURES_FILTERS: "true"
|
||||
# FEATURES_DHCP_SERVER_CONFIG: "true"
|
||||
# FEATURES_DHCP_STATIC_LEASES: "true"
|
||||
# FEATURES_DNS_SERVER_CONFIG: "true"
|
||||
# FEATURES_DNS_ACCESS_LISTS: "true"
|
||||
# FEATURES_DNS_REWRITES: "true"
|
||||
# FEATURES_THEME: "true" # if false the UI theme is not synced
|
||||
ports:
|
||||
- 8080:8080
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
### Unraid
|
||||
|
||||
Note when running the Docker container in Unraid please remove unneeded env variables if don't needed.
|
||||
If replica2 isn't used this can cause sync errors.
|
||||
|
||||
### Config file
|
||||
|
||||
location: $HOME/.adguardhome-sync.yaml
|
||||
|
||||
```yaml
|
||||
# cron expression to run in daemon mode. (default; "" = runs only once)
|
||||
cron: "*/10 * * * *"
|
||||
cron: "0 */2 * * *"
|
||||
|
||||
# runs the synchronisation on startup
|
||||
runOnStart: true
|
||||
@@ -240,9 +299,18 @@ api:
|
||||
|
||||
# enable metrics on path '/metrics' (api port must be != 0)
|
||||
# metrics:
|
||||
# enabled: true
|
||||
# scrapeInterval: 30s
|
||||
# queryLogLimit: 10000
|
||||
# enabled: true
|
||||
# scrapeInterval: 30s
|
||||
# queryLogLimit: 10000
|
||||
|
||||
# enable tls for the api server
|
||||
# tls:
|
||||
# # the directory of the provided tls certs
|
||||
# certDir: /path/to/certs
|
||||
# # the name of the cert file (default: tls.crt)
|
||||
# certName: foo.crt
|
||||
# # the name of the key file (default: tls.key)
|
||||
# keyName: bar.key
|
||||
|
||||
# Configure sync features; by default all features are enabled.
|
||||
features:
|
||||
@@ -275,4 +343,9 @@ The following log levels are supported (default: info)
|
||||
## Log Format
|
||||
|
||||
Default log format is `console`.
|
||||
It can be changed to `json`by setting the environment variable: `LOG_FORMAT=json`
|
||||
It can be changed to `json` by setting the environment variable: `LOG_FORMAT=json`.
|
||||
|
||||
## Video Tutorials
|
||||
|
||||
- [Como replicar la configuración de tu servidor DNS Adguard automáticamente - Tu servidor Part #12](https://www.youtube.com/watch?v=1LPeu_JG064) (
|
||||
Spanish) by [Jonatan Castro](https://github.com/jcastro)
|
||||
|
||||
135
Taskfile.yml
135
Taskfile.yml
@@ -1,135 +0,0 @@
|
||||
version: '3'
|
||||
env:
|
||||
AGH_MODEL_VERSION: v0.107.43
|
||||
GOBIN: '{{.USER_WORKING_DIR}}/bin'
|
||||
|
||||
tasks:
|
||||
|
||||
install-go-tool:
|
||||
label: "Install {{ .TOOL_NAME }}"
|
||||
cmds:
|
||||
- go install {{ .TOOL_MODULE }}
|
||||
status:
|
||||
- test -f {{.GOBIN}}/{{.TOOL_NAME}}
|
||||
|
||||
deepcopy-gen:
|
||||
desc: Install deepcopy-gen
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: deepcopy-gen
|
||||
TOOL_MODULE: k8s.io/code-generator/cmd/deepcopy-gen
|
||||
|
||||
ginkgo:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: ginkgo
|
||||
TOOL_MODULE: github.com/onsi/ginkgo/v2/ginkgo
|
||||
|
||||
goreleaser:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: goreleaser
|
||||
TOOL_MODULE: github.com/goreleaser/goreleaser
|
||||
|
||||
golangci-lint:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: golangci-lint
|
||||
TOOL_MODULE: github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
|
||||
mockgen:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: mockgen
|
||||
TOOL_MODULE: go.uber.org/mock/mockgen
|
||||
|
||||
oapi-codegen:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: oapi-codegen
|
||||
TOOL_MODULE: github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen
|
||||
|
||||
semver:
|
||||
cmd:
|
||||
task: install-go-tool
|
||||
vars:
|
||||
TOOL_NAME: semver
|
||||
TOOL_MODULE: github.com/bakito/semver
|
||||
|
||||
lint:
|
||||
deps:
|
||||
- golangci-lint
|
||||
cmds:
|
||||
- '{{.GOBIN}}/golangci-lint run --fix'
|
||||
|
||||
tidy:
|
||||
desc: Run go mod tidy
|
||||
cmd: go mod tidy
|
||||
|
||||
generate:
|
||||
deps:
|
||||
- deepcopy-gen
|
||||
cmds:
|
||||
- mkdir -p ./tmp
|
||||
- touch ./tmp/deepcopy-gen-boilerplate.go.txt
|
||||
- '{{.GOBIN}}/deepcopy-gen -h ./tmp/deepcopy-gen-boilerplate.go.txt -i ./pkg/types'
|
||||
|
||||
mocks:
|
||||
deps:
|
||||
- mockgen
|
||||
cmds:
|
||||
- '{{.GOBIN}}/mockgen -package client -destination pkg/mocks/client/mock.go github.com/bakito/adguardhome-sync/pkg/client Client'
|
||||
- '{{.GOBIN}}/mockgen -package client -destination pkg/mocks/flags/mock.go github.com/bakito/adguardhome-sync/pkg/config Flags'
|
||||
|
||||
test:
|
||||
cmds:
|
||||
- task: generate
|
||||
- task: lint
|
||||
- task: test-ci
|
||||
|
||||
test-ci:
|
||||
deps:
|
||||
- ginkgo
|
||||
- tidy
|
||||
- mocks
|
||||
cmds:
|
||||
- '{{.GOBIN}}/ginkgo --cover --coverprofile coverage.out.tmp ./...'
|
||||
- cat coverage.out.tmp | grep -v "_generated.go" > coverage.out
|
||||
- go tool cover -func=coverage.out
|
||||
|
||||
release:
|
||||
deps:
|
||||
- semver
|
||||
- goreleaser
|
||||
cmds:
|
||||
- git tag -s $$version -m"Release $({{.GOBIN}}/semver)
|
||||
- '{{.GOBIN}}/goreleaser --clean'
|
||||
|
||||
test-release:
|
||||
deps:
|
||||
- goreleaser
|
||||
- semver
|
||||
cmds:
|
||||
- '{{.GOBIN}}/goreleaser --skip=publish --snapshot --clean'
|
||||
|
||||
model:
|
||||
deps:
|
||||
- oapi-codegen
|
||||
cmds:
|
||||
- mkdir -p tmp
|
||||
- go run openapi/main.go {{.AGH_MODEL_VERSION}}
|
||||
- '{{.GOBIN}}/oapi-codegen -package model -generate types,client -config .oapi-codegen.yaml tmp/schema.yaml > pkg/client/model/model_generated.go'
|
||||
|
||||
model-diff:
|
||||
deps:
|
||||
- oapi-codegen
|
||||
cmds:
|
||||
- go run openapi/main.go {{.AGH_MODEL_VERSION}}
|
||||
- go run openapi/main.go
|
||||
- diff tmp/schema.yaml tmp/schema-master.yaml
|
||||
26
cmd/run.go
26
cmd/run.go
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/bakito/adguardhome-sync/pkg/log"
|
||||
"github.com/bakito/adguardhome-sync/pkg/sync"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// runCmd represents the run command
|
||||
@@ -26,18 +25,16 @@ var doCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if cfg.PrintConfigOnly {
|
||||
config, err := yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
if cfg.PrintConfigOnly() {
|
||||
if err := cfg.Print(); err != nil {
|
||||
logger.Error(err)
|
||||
return err
|
||||
}
|
||||
logger.Infof("Printing adguardhome-sync config (THE APPLICATION WILL NOT START IN THIS MODE): \n%s",
|
||||
string(config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return sync.Sync(cfg)
|
||||
return sync.Sync(cfg.Get())
|
||||
},
|
||||
}
|
||||
|
||||
@@ -50,7 +47,8 @@ func init() {
|
||||
doCmd.PersistentFlags().Bool(config.FlagContinueOnError, false, "If enabled, the synchronisation task "+
|
||||
"will not fail on single errors, but will log the errors and continue.")
|
||||
|
||||
doCmd.PersistentFlags().Int(config.FlagApiPort, 8080, "Sync API Port, the API endpoint will be started to enable remote triggering; if 0 port API is disabled.")
|
||||
doCmd.PersistentFlags().
|
||||
Int(config.FlagApiPort, 8080, "Sync API Port, the API endpoint will be started to enable remote triggering; if 0 port API is disabled.")
|
||||
doCmd.PersistentFlags().String(config.FlagApiUsername, "", "Sync API username")
|
||||
doCmd.PersistentFlags().String(config.FlagApiPassword, "", "Sync API password")
|
||||
doCmd.PersistentFlags().String(config.FlagApiDarkMode, "", "API UI in dark mode")
|
||||
@@ -70,7 +68,8 @@ func init() {
|
||||
doCmd.PersistentFlags().Bool(config.FlagFeatureFilters, true, "Enable filters sync feature")
|
||||
|
||||
doCmd.PersistentFlags().String(config.FlagOriginURL, "", "Origin instance url")
|
||||
doCmd.PersistentFlags().String(config.FlagOriginWebURL, "", "Origin instance web url used in the web interface (default: <origin-url>)")
|
||||
doCmd.PersistentFlags().
|
||||
String(config.FlagOriginWebURL, "", "Origin instance web url used in the web interface (default: <origin-url>)")
|
||||
doCmd.PersistentFlags().String(config.FlagOriginApiPath, "/control", "Origin instance API path")
|
||||
doCmd.PersistentFlags().String(config.FlagOriginUsername, "", "Origin instance username")
|
||||
doCmd.PersistentFlags().String(config.FlagOriginPassword, "", "Origin instance password")
|
||||
@@ -78,12 +77,15 @@ func init() {
|
||||
doCmd.PersistentFlags().Bool(config.FlagOriginISV, false, "Enable Origin instance InsecureSkipVerify")
|
||||
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaURL, "", "Replica instance url")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaWebURL, "", "Replica instance web url used in the web interface (default: <replica-url>)")
|
||||
doCmd.PersistentFlags().
|
||||
String(config.FlagReplicaWebURL, "", "Replica instance web url used in the web interface (default: <replica-url>)")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaApiPath, "/control", "Replica instance API path")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaUsername, "", "Replica instance username")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaPassword, "", "Replica instance password")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaCookie, "", "If Set, uses a cookie for authentication")
|
||||
doCmd.PersistentFlags().Bool(config.FlagReplicaISV, false, "Enable Replica instance InsecureSkipVerify")
|
||||
doCmd.PersistentFlags().Bool(config.FlagReplicaAutoSetup, false, "Enable automatic setup of new AdguardHome instances. This replaces the setup wizard.")
|
||||
doCmd.PersistentFlags().String(config.FlagReplicaInterfaceName, "", "Optional change the interface name of the replica if it differs from the master")
|
||||
doCmd.PersistentFlags().
|
||||
Bool(config.FlagReplicaAutoSetup, false, "Enable automatic setup of new AdguardHome instances. This replaces the setup wizard.")
|
||||
doCmd.PersistentFlags().
|
||||
String(config.FlagReplicaInterfaceName, "", "Optional change the interface name of the replica if it differs from the master")
|
||||
}
|
||||
|
||||
442
go.mod
442
go.mod
@@ -1,432 +1,78 @@
|
||||
module github.com/bakito/adguardhome-sync
|
||||
|
||||
go 1.22
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/bakito/semver v1.1.3
|
||||
github.com/caarlos0/env/v10 v10.0.0
|
||||
github.com/deepmap/oapi-codegen/v2 v2.1.0
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/go-resty/resty/v2 v2.12.0
|
||||
github.com/golangci/golangci-lint v1.57.2
|
||||
github.com/caarlos0/env/v11 v11.3.1
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/go-faker/faker/v4 v4.6.0
|
||||
github.com/go-resty/resty/v2 v2.16.5
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/goreleaser/goreleaser v1.24.0
|
||||
github.com/jinzhu/copier v0.4.0
|
||||
github.com/oapi-codegen/runtime v1.1.1
|
||||
github.com/onsi/ginkgo/v2 v2.17.1
|
||||
github.com/onsi/gomega v1.32.0
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/onsi/ginkgo/v2 v2.23.0
|
||||
github.com/onsi/gomega v1.36.2
|
||||
github.com/prometheus/client_golang v1.21.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/spf13/cobra v1.8.0
|
||||
go.uber.org/mock v0.4.0
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1
|
||||
github.com/spf13/cobra v1.9.1
|
||||
go.uber.org/mock v0.5.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
|
||||
golang.org/x/mod v0.16.0
|
||||
golang.org/x/mod v0.24.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/apimachinery v0.29.3
|
||||
k8s.io/code-generator v0.29.3
|
||||
k8s.io/apimachinery v0.32.3
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758
|
||||
)
|
||||
|
||||
require (
|
||||
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
||||
4d63.com/gochecknoglobals v0.2.1 // indirect
|
||||
cloud.google.com/go v0.110.10 // indirect
|
||||
cloud.google.com/go/compute v1.23.3 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/iam v1.1.5 // indirect
|
||||
cloud.google.com/go/kms v1.15.5 // indirect
|
||||
cloud.google.com/go/storage v1.35.1 // indirect
|
||||
code.gitea.io/sdk/gitea v0.17.1 // indirect
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/4meepo/tagalign v1.3.3 // indirect
|
||||
github.com/Abirdcfly/dupword v0.0.14 // indirect
|
||||
github.com/AlekSi/pointer v1.2.0 // indirect
|
||||
github.com/Antonboom/errname v0.1.12 // indirect
|
||||
github.com/Antonboom/nilnil v0.1.7 // indirect
|
||||
github.com/Antonboom/testifylint v1.2.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys v0.10.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 // indirect
|
||||
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
|
||||
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
|
||||
github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect
|
||||
github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
|
||||
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
|
||||
github.com/Azure/go-autorest/logger v0.2.1 // indirect
|
||||
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
|
||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.2.1 // indirect
|
||||
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.0.0 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.1.4 // indirect
|
||||
github.com/alessio/shellescape v1.4.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.4 // indirect
|
||||
github.com/alexkohler/prealloc v1.0.0 // indirect
|
||||
github.com/alingse/asasalint v0.0.11 // indirect
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/ashanbrown/forbidigo v1.6.0 // indirect
|
||||
github.com/ashanbrown/makezero v1.1.1 // indirect
|
||||
github.com/atc0005/go-teams-notify/v2 v2.9.0 // indirect
|
||||
github.com/aws/aws-sdk-go v1.50.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.26.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.16.12 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.15.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.20.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.18.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/kms v1.27.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.47.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.26.5 // indirect
|
||||
github.com/aws/smithy-go v1.19.0 // indirect
|
||||
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20231024185945-8841054dbdb8 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bkielbasa/cyclop v1.2.1 // indirect
|
||||
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect
|
||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
||||
github.com/bombsimon/wsl/v4 v4.2.1 // indirect
|
||||
github.com/breml/bidichk v0.2.7 // indirect
|
||||
github.com/breml/errchkjson v0.3.6 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/butuzov/ireturn v0.3.0 // indirect
|
||||
github.com/butuzov/mirror v1.1.0 // indirect
|
||||
github.com/bytedance/sonic v1.10.2 // indirect
|
||||
github.com/caarlos0/ctrlc v1.2.0 // indirect
|
||||
github.com/caarlos0/env/v9 v9.0.0 // indirect
|
||||
github.com/caarlos0/go-reddit/v3 v3.0.1 // indirect
|
||||
github.com/caarlos0/go-shellwords v1.0.12 // indirect
|
||||
github.com/caarlos0/go-version v0.1.1 // indirect
|
||||
github.com/caarlos0/log v0.4.4 // indirect
|
||||
github.com/catenacyber/perfsprint v0.7.1 // indirect
|
||||
github.com/cavaliergopher/cpio v1.0.1 // indirect
|
||||
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/charithe/durationcheck v0.0.10 // indirect
|
||||
github.com/charmbracelet/lipgloss v0.9.1 // indirect
|
||||
github.com/charmbracelet/x/exp/ordered v0.0.0-20231010190216-1cb11efc897d // indirect
|
||||
github.com/chavacava/garif v0.1.0 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect
|
||||
github.com/ckaznocha/intrange v0.1.1 // indirect
|
||||
github.com/cloudflare/circl v1.3.7 // indirect
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
|
||||
github.com/curioswitch/go-reassign v0.2.0 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
|
||||
github.com/daixiang0/gci v0.12.3 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/davidmz/go-pageant v1.0.2 // indirect
|
||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
||||
github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb // indirect
|
||||
github.com/dghubble/oauth1 v0.7.2 // indirect
|
||||
github.com/dghubble/sling v1.4.0 // indirect
|
||||
github.com/dimchansky/utfbom v1.1.1 // indirect
|
||||
github.com/distribution/reference v0.5.0 // indirect
|
||||
github.com/docker/cli v24.0.7+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.3+incompatible // indirect
|
||||
github.com/docker/docker v24.0.9+incompatible // indirect
|
||||
github.com/docker/docker-credential-helpers v0.8.0 // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/firefart/nonamedreturns v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/getkin/kin-openapi v0.122.0 // indirect
|
||||
github.com/ghostiam/protogetter v0.3.5 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-critic/go-critic v0.11.2 // indirect
|
||||
github.com/go-fed/httpsig v1.1.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.5.0 // indirect
|
||||
github.com/go-git/go-git/v5 v5.11.0 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-openapi/analysis v0.21.4 // indirect
|
||||
github.com/go-openapi/errors v0.20.4 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.20.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/loads v0.21.2 // indirect
|
||||
github.com/go-openapi/runtime v0.26.0 // indirect
|
||||
github.com/go-openapi/spec v0.20.9 // indirect
|
||||
github.com/go-openapi/strfmt v0.21.7 // indirect
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/go-openapi/validate v0.22.1 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.16.0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astequal v1.2.0 // indirect
|
||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/gofrs/flock v0.8.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.1.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
|
||||
github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e // indirect
|
||||
github.com/golangci/misspell v0.4.1 // indirect
|
||||
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
||||
github.com/golangci/revgrep v0.5.2 // indirect
|
||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/go-containerregistry v0.19.0 // indirect
|
||||
github.com/google/go-github/v57 v57.0.0 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/ko v0.15.1 // indirect
|
||||
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect
|
||||
github.com/google/rpmpack v0.5.0 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
|
||||
github.com/google/wire v0.5.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
|
||||
github.com/gordonklaus/ineffassign v0.1.0 // indirect
|
||||
github.com/goreleaser/chglog v0.5.0 // indirect
|
||||
github.com/goreleaser/fileglob v1.3.0 // indirect
|
||||
github.com/goreleaser/nfpm/v2 v2.35.3 // indirect
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
|
||||
github.com/gostaticanalysis/comment v1.4.2 // indirect
|
||||
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
|
||||
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
|
||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/huandu/xstrings v1.3.3 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/invopop/jsonschema v0.12.0 // indirect
|
||||
github.com/invopop/yaml v0.2.0 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/jgautheron/goconst v1.7.1 // indirect
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
||||
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
|
||||
github.com/jjti/go-spancheck v0.5.3 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/julz/importas v0.1.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.0.10 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/kisielk/errcheck v1.7.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
|
||||
github.com/klauspost/compress v1.17.5 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||
github.com/klauspost/pgzip v1.2.6 // indirect
|
||||
github.com/kulti/thelper v0.6.3 // indirect
|
||||
github.com/kunwardeep/paralleltest v1.0.10 // indirect
|
||||
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||
github.com/kyoh86/exportloopref v0.1.11 // indirect
|
||||
github.com/ldez/gomoddirectives v0.2.4 // indirect
|
||||
github.com/ldez/tagliatelle v0.5.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/leonklingele/grouper v1.1.1 // indirect
|
||||
github.com/letsencrypt/boulder v0.0.0-20231026200631-000cd05d5491 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/lufeee/execinquery v1.2.1 // indirect
|
||||
github.com/macabu/inamedparam v0.1.3 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/maratori/testableexamples v1.0.0 // indirect
|
||||
github.com/maratori/testpackage v1.1.1 // indirect
|
||||
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-mastodon v0.0.6 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/mgechev/revive v1.3.7 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/moricho/tparallel v0.3.1 // indirect
|
||||
github.com/muesli/mango v0.1.0 // indirect
|
||||
github.com/muesli/mango-cobra v1.2.0 // indirect
|
||||
github.com/muesli/mango-pflag v0.1.0 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/roff v0.1.0 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.16.2 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
|
||||
github.com/perimeterx/marshmallow v1.1.5 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/polyfloyd/go-errorlint v1.4.8 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/quasilyte/go-ruleguard v0.4.2 // indirect
|
||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
||||
github.com/rivo/uniseg v0.4.2 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/ryancurrah/gomodguard v1.3.1 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.3.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
|
||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
||||
github.com/sashamelentyev/usestdlibvars v1.25.0 // indirect
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
|
||||
github.com/securego/gosec/v2 v2.19.0 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
|
||||
github.com/shopspring/decimal v1.2.0 // indirect
|
||||
github.com/sigstore/cosign/v2 v2.2.1 // indirect
|
||||
github.com/sigstore/rekor v1.3.3 // indirect
|
||||
github.com/sigstore/sigstore v1.7.5 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
||||
github.com/sivchari/tenv v1.7.1 // indirect
|
||||
github.com/skeema/knownhosts v1.2.1 // indirect
|
||||
github.com/slack-go/slack v0.12.3 // indirect
|
||||
github.com/sonatard/noctx v0.0.2 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.5.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.17.0 // indirect
|
||||
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
|
||||
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/stretchr/testify v1.9.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
|
||||
github.com/tdakkota/asciicheck v0.2.0 // indirect
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
||||
github.com/tetafro/godot v1.4.16 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect
|
||||
github.com/timonwong/loggercheck v0.9.4 // indirect
|
||||
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
|
||||
github.com/tomarrell/wrapcheck/v2 v2.8.3 // indirect
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
github.com/ultraware/funlen v0.1.0 // indirect
|
||||
github.com/ultraware/whitespace v0.1.0 // indirect
|
||||
github.com/uudashr/gocognit v1.1.2 // indirect
|
||||
github.com/vbatts/tar-split v0.11.5 // indirect
|
||||
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
github.com/xanzy/go-gitlab v0.97.0 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
github.com/xen0n/gosmopolitan v1.2.2 // indirect
|
||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
||||
github.com/yeya24/promlinter v0.2.0 // indirect
|
||||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
||||
gitlab.com/bosi/decorder v0.4.1 // indirect
|
||||
gitlab.com/digitalxero/go-conventional-commit v1.0.7 // indirect
|
||||
go-simpler.org/musttag v0.9.0 // indirect
|
||||
go-simpler.org/sloglint v0.5.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.12.1 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
gocloud.dev v0.36.0 // indirect
|
||||
golang.org/x/arch v0.7.0 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/oauth2 v0.16.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/term v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.19.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
|
||||
google.golang.org/api v0.152.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
|
||||
google.golang.org/grpc v1.59.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.35.0 // indirect
|
||||
golang.org/x/net v0.36.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/mail.v2 v2.3.1 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
honnef.co/go/tools v0.4.7 // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/klog/v2 v2.110.1 // indirect
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||
mvdan.cc/gofumpt v0.6.0 // indirect
|
||||
mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
sigs.k8s.io/kind v0.20.0 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||
k8s.io/klog/v2 v2.130.1 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
@@ -20,7 +20,9 @@ func main() {
|
||||
}
|
||||
log.Printf("Patching schema version %s\n", version)
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf("https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/%s/openapi/openapi.yaml", version))
|
||||
resp, err := http.Get(
|
||||
fmt.Sprintf("https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/%s/openapi/openapi.yaml", version),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
@@ -51,6 +53,11 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
correctEntries(schema)
|
||||
|
||||
addFakeTags(schema)
|
||||
|
||||
b, err := yaml.Marshal(&schema)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
@@ -61,3 +68,26 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func correctEntries(schema map[string]interface{}) {
|
||||
// https://github.com/AdguardTeam/AdGuardHome/pull/7678
|
||||
if err := unstructured.SetNestedField(schema, "string", "components", "schemas", "QueryLogItem", "properties", "client_proto", "type"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func addFakeTags(schema map[string]interface{}) {
|
||||
fake := map[string]interface{}{"faker": `slice_len=24`}
|
||||
if err := unstructured.SetNestedMap(schema, fake, "components", "schemas", "Stats", "properties", "blocked_filtering", "x-oapi-codegen-extra-tags"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
if err := unstructured.SetNestedMap(schema, fake, "components", "schemas", "Stats", "properties", "dns_queries", "x-oapi-codegen-extra-tags"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
if err := unstructured.SetNestedMap(schema, fake, "components", "schemas", "Stats", "properties", "replaced_parental", "x-oapi-codegen-extra-tags"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
if err := unstructured.SetNestedMap(schema, fake, "components", "schemas", "Stats", "properties", "replaced_safebrowsing", "x-oapi-codegen-extra-tags"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,10 @@ func (cl *client) Stats() (*model.Stats, error) {
|
||||
|
||||
func (cl *client) QueryLog(limit int) (*model.QueryLog, error) {
|
||||
ql := &model.QueryLog{}
|
||||
err := cl.doGet(cl.client.R().EnableTrace().SetResult(ql), fmt.Sprintf(`querylog?limit=%d&response_status="all"`, limit))
|
||||
err := cl.doGet(
|
||||
cl.client.R().EnableTrace().SetResult(ql),
|
||||
fmt.Sprintf(`querylog?limit=%d&response_status="all"`, limit),
|
||||
)
|
||||
return ql, err
|
||||
}
|
||||
|
||||
@@ -260,7 +263,10 @@ func (cl *client) UpdateFilter(whitelist bool, f model.Filter) error {
|
||||
|
||||
func (cl *client) RefreshFilters(whitelist bool) error {
|
||||
cl.log.With("whitelist", whitelist).Info("Refresh filter")
|
||||
return cl.doPost(cl.client.R().EnableTrace().SetBody(&model.FilterRefreshRequest{Whitelist: utils.Ptr(whitelist)}), "/filtering/refresh")
|
||||
return cl.doPost(
|
||||
cl.client.R().EnableTrace().SetBody(&model.FilterRefreshRequest{Whitelist: utils.Ptr(whitelist)}),
|
||||
"/filtering/refresh",
|
||||
)
|
||||
}
|
||||
|
||||
func (cl *client) ToggleProtection(enable bool) error {
|
||||
@@ -309,7 +315,10 @@ func (cl *client) AddClient(client *model.Client) error {
|
||||
|
||||
func (cl *client) UpdateClient(client *model.Client) error {
|
||||
cl.log.With("name", *client.Name).Info("Update client settings")
|
||||
return cl.doPost(cl.client.R().EnableTrace().SetBody(&model.ClientUpdate{Name: client.Name, Data: client}), "/clients/update")
|
||||
return cl.doPost(
|
||||
cl.client.R().EnableTrace().SetBody(&model.ClientUpdate{Name: client.Name, Data: client}),
|
||||
"/clients/update",
|
||||
)
|
||||
}
|
||||
|
||||
func (cl *client) DeleteClient(client *model.Client) error {
|
||||
@@ -324,7 +333,8 @@ func (cl *client) QueryLogConfig() (*model.QueryLogConfigWithIgnored, error) {
|
||||
}
|
||||
|
||||
func (cl *client) SetQueryLogConfig(qlc *model.QueryLogConfigWithIgnored) error {
|
||||
cl.log.With("enabled", *qlc.Enabled, "interval", *qlc.Interval, "anonymizeClientIP", *qlc.AnonymizeClientIp).Info("Set query log config")
|
||||
cl.log.With("enabled", *qlc.Enabled, "interval", *qlc.Interval, "anonymizeClientIP", *qlc.AnonymizeClientIp).
|
||||
Info("Set query log config")
|
||||
return cl.doPut(cl.client.R().EnableTrace().SetBody(qlc), "/querylog/config/update")
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,14 @@ var _ = Describe("Client", func() {
|
||||
|
||||
Context("Setup", func() {
|
||||
It("should add setup the instance", func() {
|
||||
ts, cl = ClientPost("/install/configure", fmt.Sprintf(`{"web":{"ip":"0.0.0.0","port":3000,"status":"","can_autofix":false},"dns":{"ip":"0.0.0.0","port":53,"status":"","can_autofix":false},"username":"%s","password":"%s"}`, username, password))
|
||||
ts, cl = ClientPost(
|
||||
"/install/configure",
|
||||
fmt.Sprintf(
|
||||
`{"web":{"ip":"0.0.0.0","port":3000,"status":"","can_autofix":false},"dns":{"ip":"0.0.0.0","port":53,"status":"","can_autofix":false},"username":"%s","password":"%s"}`,
|
||||
username,
|
||||
password,
|
||||
),
|
||||
)
|
||||
err := cl.Setup()
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
@@ -303,7 +310,10 @@ var _ = Describe("Client", func() {
|
||||
Ω(*qlc.Interval).Should(Equal(model.QueryLogConfigInterval(90)))
|
||||
})
|
||||
It("should set QueryLogConfig", func() {
|
||||
ts, cl = ClientPut("/querylog/config/update", `{"anonymize_client_ip":true,"enabled":true,"interval":123,"ignored":["foo.bar"]}`)
|
||||
ts, cl = ClientPut(
|
||||
"/querylog/config/update",
|
||||
`{"anonymize_client_ip":true,"enabled":true,"interval":123,"ignored":["foo.bar"]}`,
|
||||
)
|
||||
|
||||
var interval model.QueryLogConfigInterval = 123
|
||||
err := cl.SetQueryLogConfig(&model.QueryLogConfigWithIgnored{
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/bakito/adguardhome-sync/pkg/utils"
|
||||
"github.com/jinzhu/copier"
|
||||
"go.uber.org/zap"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
// Clone the config
|
||||
@@ -167,11 +168,40 @@ func (cl *Client) Sort() {
|
||||
}
|
||||
}
|
||||
|
||||
// PrepareDiff timezone BlockedServicesSchedule might differ if all other fields are empty,
|
||||
// so we skip it in diff
|
||||
func (cl *Client) PrepareDiff() *string {
|
||||
var tz *string
|
||||
bss := cl.BlockedServicesSchedule
|
||||
if bss != nil && bss.Mon == nil && bss.Tue == nil && bss.Wed == nil &&
|
||||
bss.Thu == nil && bss.Fri == nil && bss.Sat == nil && bss.Sun == nil {
|
||||
|
||||
tz = cl.BlockedServicesSchedule.TimeZone
|
||||
cl.BlockedServicesSchedule.TimeZone = nil
|
||||
}
|
||||
return tz
|
||||
}
|
||||
|
||||
// AfterDiff reset after diff
|
||||
func (cl *Client) AfterDiff(tz *string) {
|
||||
if cl.BlockedServicesSchedule != nil {
|
||||
cl.BlockedServicesSchedule.TimeZone = tz
|
||||
}
|
||||
}
|
||||
|
||||
// Equals Clients equal check
|
||||
func (cl *Client) Equals(o *Client) bool {
|
||||
cl.Sort()
|
||||
o.Sort()
|
||||
|
||||
bssCl := cl.PrepareDiff()
|
||||
bssO := o.PrepareDiff()
|
||||
|
||||
defer func() {
|
||||
cl.AfterDiff(bssCl)
|
||||
o.AfterDiff(bssO)
|
||||
}()
|
||||
|
||||
return utils.JsonEquals(cl, o)
|
||||
}
|
||||
|
||||
@@ -369,23 +399,22 @@ func (ssc *SafeSearchConfig) Equals(o *SafeSearchConfig) bool {
|
||||
ptrEquals(ssc.Youtube, o.Youtube)
|
||||
}
|
||||
|
||||
func (pi *ProfileInfo) Equals(o *ProfileInfo) bool {
|
||||
return pi.Language == o.Language &&
|
||||
pi.Theme == o.Theme
|
||||
func (pi *ProfileInfo) Equals(o *ProfileInfo, withTheme bool) bool {
|
||||
return pi.Language == o.Language && (!withTheme || pi.Theme == o.Theme)
|
||||
}
|
||||
|
||||
func (pi *ProfileInfo) ShouldSyncFor(o *ProfileInfo) *ProfileInfo {
|
||||
if pi.Equals(o) {
|
||||
func (pi *ProfileInfo) ShouldSyncFor(o *ProfileInfo, withTheme bool) *ProfileInfo {
|
||||
if pi.Equals(o, withTheme) {
|
||||
return nil
|
||||
}
|
||||
merged := &ProfileInfo{Name: pi.Name, Language: pi.Language, Theme: pi.Theme}
|
||||
if o.Language != "" {
|
||||
merged.Language = o.Language
|
||||
}
|
||||
if o.Theme != "" {
|
||||
if withTheme && o.Theme != "" {
|
||||
merged.Theme = o.Theme
|
||||
}
|
||||
if merged.Name == "" || merged.Language == "" || merged.Theme == "" || merged.Equals(pi) {
|
||||
if merged.Name == "" || merged.Language == "" || merged.Equals(pi, false) {
|
||||
return nil
|
||||
}
|
||||
return merged
|
||||
@@ -410,9 +439,12 @@ func ArrayString(a *[]string) string {
|
||||
|
||||
func (c *DNSConfig) Sanitize(l *zap.SugaredLogger) {
|
||||
// disable UsePrivatePtrResolvers if not configured
|
||||
// https://github.com/AdguardTeam/AdGuardHome/issues/6820
|
||||
if c.UsePrivatePtrResolvers != nil && *c.UsePrivatePtrResolvers &&
|
||||
(c.LocalPtrUpstreams == nil || len(*c.LocalPtrUpstreams) == 0) {
|
||||
l.Warn("disabling replica 'Use private reverse DNS resolvers' as no 'Private reverse DNS servers' are configured on origin")
|
||||
l.Warn(
|
||||
"disabling replica 'Use private reverse DNS resolvers' as no 'Private reverse DNS servers' are configured on origin",
|
||||
)
|
||||
c.UsePrivatePtrResolvers = utils.Ptr(false)
|
||||
}
|
||||
}
|
||||
@@ -421,3 +453,53 @@ func (c *DNSConfig) Sanitize(l *zap.SugaredLogger) {
|
||||
func (sc *GetStatsConfigResponse) Equals(o *GetStatsConfigResponse) bool {
|
||||
return utils.JsonEquals(sc, o)
|
||||
}
|
||||
|
||||
func NewStats() *Stats {
|
||||
return &Stats{
|
||||
NumBlockedFiltering: ptr.To(0),
|
||||
NumReplacedParental: ptr.To(0),
|
||||
NumReplacedSafesearch: ptr.To(0),
|
||||
NumReplacedSafebrowsing: ptr.To(0),
|
||||
NumDnsQueries: ptr.To(0),
|
||||
|
||||
BlockedFiltering: ptr.To(make([]int, 24)),
|
||||
DnsQueries: ptr.To(make([]int, 24)),
|
||||
ReplacedParental: ptr.To(make([]int, 24)),
|
||||
ReplacedSafebrowsing: ptr.To(make([]int, 24)),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Stats) Add(other *Stats) {
|
||||
s.NumBlockedFiltering = addInt(s.NumBlockedFiltering, other.NumBlockedFiltering)
|
||||
s.NumReplacedSafebrowsing = addInt(s.NumReplacedSafebrowsing, other.NumReplacedSafebrowsing)
|
||||
s.NumDnsQueries = addInt(s.NumDnsQueries, other.NumDnsQueries)
|
||||
s.NumReplacedSafesearch = addInt(s.NumReplacedSafesearch, other.NumReplacedSafesearch)
|
||||
s.NumReplacedParental = addInt(s.NumReplacedParental, other.NumReplacedParental)
|
||||
|
||||
s.BlockedFiltering = sumUp(s.BlockedFiltering, other.BlockedFiltering)
|
||||
s.DnsQueries = sumUp(s.DnsQueries, other.DnsQueries)
|
||||
s.ReplacedParental = sumUp(s.ReplacedParental, other.ReplacedParental)
|
||||
s.ReplacedSafebrowsing = sumUp(s.ReplacedSafebrowsing, other.ReplacedSafebrowsing)
|
||||
}
|
||||
|
||||
func addInt(t *int, add *int) *int {
|
||||
if add != nil {
|
||||
return ptr.To(*t + *add)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func sumUp(t *[]int, o *[]int) *[]int {
|
||||
if o != nil {
|
||||
tt := *t
|
||||
oo := *o
|
||||
var sum []int
|
||||
for i := 0; i < len(tt); i++ {
|
||||
if len(oo) >= i {
|
||||
sum = append(sum, tt[i]+oo[i])
|
||||
}
|
||||
}
|
||||
return &sum
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package model provides primitives to interact with the openapi HTTP API.
|
||||
//
|
||||
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.
|
||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
|
||||
package model
|
||||
|
||||
import (
|
||||
@@ -91,6 +91,15 @@ const (
|
||||
QueryLogConfigIntervalN90 QueryLogConfigInterval = 90
|
||||
)
|
||||
|
||||
// Defines values for QueryLogItemClientProto.
|
||||
const (
|
||||
Dnscrypt QueryLogItemClientProto = "dnscrypt"
|
||||
Doh QueryLogItemClientProto = "doh"
|
||||
Doq QueryLogItemClientProto = "doq"
|
||||
Dot QueryLogItemClientProto = "dot"
|
||||
Empty QueryLogItemClientProto = ""
|
||||
)
|
||||
|
||||
// Defines values for QueryLogItemReason.
|
||||
const (
|
||||
QueryLogItemReasonFilteredBlackList QueryLogItemReason = "FilteredBlackList"
|
||||
@@ -397,6 +406,17 @@ type ClientsFindEntry map[string]ClientFindSubEntry
|
||||
// ClientsFindResponse Client search results.
|
||||
type ClientsFindResponse = []ClientsFindEntry
|
||||
|
||||
// ClientsSearchRequest Client search request
|
||||
type ClientsSearchRequest struct {
|
||||
Clients *[]ClientsSearchRequestItem `json:"clients,omitempty"`
|
||||
}
|
||||
|
||||
// ClientsSearchRequestItem defines model for ClientsSearchRequestItem.
|
||||
type ClientsSearchRequestItem struct {
|
||||
// Id Client IP address, CIDR, MAC address, or ClientID
|
||||
Id *string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
// DNSConfig DNS server configuration
|
||||
type DNSConfig struct {
|
||||
// BlockedResponseTtl TTL for blocked responses.
|
||||
@@ -443,8 +463,11 @@ type DNSConfig struct {
|
||||
UpstreamDnsFile *string `json:"upstream_dns_file,omitempty"`
|
||||
|
||||
// UpstreamMode Upstream modes enumeration.
|
||||
UpstreamMode *DNSConfigUpstreamMode `json:"upstream_mode,omitempty"`
|
||||
UsePrivatePtrResolvers *bool `json:"use_private_ptr_resolvers,omitempty"`
|
||||
UpstreamMode *DNSConfigUpstreamMode `json:"upstream_mode,omitempty"`
|
||||
|
||||
// UpstreamTimeout The number of seconds to wait for a response from the upstream server
|
||||
UpstreamTimeout *int `json:"upstream_timeout,omitempty"`
|
||||
UsePrivatePtrResolvers *bool `json:"use_private_ptr_resolvers,omitempty"`
|
||||
}
|
||||
|
||||
// DNSConfigBlockingMode defines model for DNSConfig.BlockingMode.
|
||||
@@ -725,11 +748,18 @@ type Login struct {
|
||||
// NetInterface Network interface info
|
||||
type NetInterface struct {
|
||||
// Flags Flags could be any combination of the following values, divided by the "|" character: "up", "broadcast", "loopback", "pointtopoint" and "multicast".
|
||||
Flags string `json:"flags"`
|
||||
HardwareAddress string `json:"hardware_address"`
|
||||
IpAddresses *[]string `json:"ip_addresses,omitempty"`
|
||||
Mtu int `json:"mtu"`
|
||||
Name string `json:"name"`
|
||||
Flags string `json:"flags"`
|
||||
|
||||
// GatewayIp The IP address of the gateway.
|
||||
GatewayIp string `json:"gateway_ip"`
|
||||
HardwareAddress string `json:"hardware_address"`
|
||||
|
||||
// Ipv4Addresses The addresses of the interface of v4 family.
|
||||
Ipv4Addresses []string `json:"ipv4_addresses"`
|
||||
|
||||
// Ipv6Addresses The addresses of the interface of v6 family.
|
||||
Ipv6Addresses []string `json:"ipv6_addresses"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// NetInterfaces Network interfaces dictionary, keys are interface names.
|
||||
@@ -791,8 +821,8 @@ type QueryLogItem struct {
|
||||
ClientId *string `json:"client_id,omitempty"`
|
||||
|
||||
// ClientInfo Client information for a query log item.
|
||||
ClientInfo *QueryLogItemClient `json:"client_info,omitempty"`
|
||||
ClientProto *interface{} `json:"client_proto,omitempty"`
|
||||
ClientInfo *QueryLogItemClient `json:"client_info,omitempty"`
|
||||
ClientProto *QueryLogItemClientProto `json:"client_proto,omitempty"`
|
||||
|
||||
// Ecs The IP network defined by an EDNS Client-Subnet option in the request message if any.
|
||||
Ecs *string `json:"ecs,omitempty"`
|
||||
@@ -833,6 +863,9 @@ type QueryLogItem struct {
|
||||
Upstream *string `json:"upstream,omitempty"`
|
||||
}
|
||||
|
||||
// QueryLogItemClientProto defines model for QueryLogItem.ClientProto.
|
||||
type QueryLogItemClientProto string
|
||||
|
||||
// QueryLogItemReason Request filtering status.
|
||||
type QueryLogItemReason string
|
||||
|
||||
@@ -904,6 +937,7 @@ type RewriteUpdate struct {
|
||||
type SafeSearchConfig struct {
|
||||
Bing *bool `json:"bing,omitempty"`
|
||||
Duckduckgo *bool `json:"duckduckgo,omitempty"`
|
||||
Ecosia *bool `json:"ecosia,omitempty"`
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
Google *bool `json:"google,omitempty"`
|
||||
Pixabay *bool `json:"pixabay,omitempty"`
|
||||
@@ -967,8 +1001,8 @@ type SetRulesRequest struct {
|
||||
type Stats struct {
|
||||
// AvgProcessingTime Average time in seconds on processing a DNS request
|
||||
AvgProcessingTime *float32 `json:"avg_processing_time,omitempty"`
|
||||
BlockedFiltering *[]int `json:"blocked_filtering,omitempty"`
|
||||
DnsQueries *[]int `json:"dns_queries,omitempty"`
|
||||
BlockedFiltering *[]int `faker:"slice_len=24" json:"blocked_filtering,omitempty"`
|
||||
DnsQueries *[]int `faker:"slice_len=24" json:"dns_queries,omitempty"`
|
||||
|
||||
// NumBlockedFiltering Number of requests blocked by filtering rules
|
||||
NumBlockedFiltering *int `json:"num_blocked_filtering,omitempty"`
|
||||
@@ -984,8 +1018,8 @@ type Stats struct {
|
||||
|
||||
// NumReplacedSafesearch Number of requests blocked by safesearch module
|
||||
NumReplacedSafesearch *int `json:"num_replaced_safesearch,omitempty"`
|
||||
ReplacedParental *[]int `json:"replaced_parental,omitempty"`
|
||||
ReplacedSafebrowsing *[]int `json:"replaced_safebrowsing,omitempty"`
|
||||
ReplacedParental *[]int `faker:"slice_len=24" json:"replaced_parental,omitempty"`
|
||||
ReplacedSafebrowsing *[]int `faker:"slice_len=24" json:"replaced_safebrowsing,omitempty"`
|
||||
|
||||
// TimeUnits Time units
|
||||
TimeUnits *StatsTimeUnits `json:"time_units,omitempty"`
|
||||
@@ -1204,6 +1238,9 @@ type ClientsAddJSONRequestBody = Client
|
||||
// ClientsDeleteJSONRequestBody defines body for ClientsDelete for application/json ContentType.
|
||||
type ClientsDeleteJSONRequestBody = ClientDelete
|
||||
|
||||
// ClientsSearchJSONRequestBody defines body for ClientsSearch for application/json ContentType.
|
||||
type ClientsSearchJSONRequestBody = ClientsSearchRequest
|
||||
|
||||
// ClientsUpdateJSONRequestBody defines body for ClientsUpdate for application/json ContentType.
|
||||
type ClientsUpdateJSONRequestBody = ClientUpdate
|
||||
|
||||
@@ -1493,6 +1530,11 @@ type ClientInterface interface {
|
||||
// ClientsFind request
|
||||
ClientsFind(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// ClientsSearchWithBody request with any body
|
||||
ClientsSearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
ClientsSearch(ctx context.Context, body ClientsSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// ClientsUpdateWithBody request with any body
|
||||
ClientsUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
@@ -1985,6 +2027,30 @@ func (c *AdguardHomeClient) ClientsFind(ctx context.Context, params *ClientsFind
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *AdguardHomeClient) ClientsSearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewClientsSearchRequestWithBody(c.Server, contentType, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *AdguardHomeClient) ClientsSearch(ctx context.Context, body ClientsSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewClientsSearchRequest(c.Server, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *AdguardHomeClient) ClientsUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewClientsUpdateRequestWithBody(c.Server, contentType, body)
|
||||
if err != nil {
|
||||
@@ -3673,6 +3739,46 @@ func NewClientsFindRequest(server string, params *ClientsFindParams) (*http.Requ
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// NewClientsSearchRequest calls the generic ClientsSearch builder with application/json body
|
||||
func NewClientsSearchRequest(server string, body ClientsSearchJSONRequestBody) (*http.Request, error) {
|
||||
var bodyReader io.Reader
|
||||
buf, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bodyReader = bytes.NewReader(buf)
|
||||
return NewClientsSearchRequestWithBody(server, "application/json", bodyReader)
|
||||
}
|
||||
|
||||
// NewClientsSearchRequestWithBody generates requests for ClientsSearch with any type of body
|
||||
func NewClientsSearchRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
|
||||
var err error
|
||||
|
||||
serverURL, err := url.Parse(server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
operationPath := fmt.Sprintf("/clients/search")
|
||||
if operationPath[0] == '/' {
|
||||
operationPath = "." + operationPath
|
||||
}
|
||||
|
||||
queryURL, err := serverURL.Parse(operationPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", queryURL.String(), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Add("Content-Type", contentType)
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// NewClientsUpdateRequest calls the generic ClientsUpdate builder with application/json body
|
||||
func NewClientsUpdateRequest(server string, body ClientsUpdateJSONRequestBody) (*http.Request, error) {
|
||||
var bodyReader io.Reader
|
||||
@@ -5983,6 +6089,11 @@ type ClientWithResponsesInterface interface {
|
||||
// ClientsFindWithResponse request
|
||||
ClientsFindWithResponse(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*ClientsFindResp, error)
|
||||
|
||||
// ClientsSearchWithBodyWithResponse request with any body
|
||||
ClientsSearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsSearchResp, error)
|
||||
|
||||
ClientsSearchWithResponse(ctx context.Context, body ClientsSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsSearchResp, error)
|
||||
|
||||
// ClientsUpdateWithBodyWithResponse request with any body
|
||||
ClientsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error)
|
||||
|
||||
@@ -6559,6 +6670,28 @@ func (r ClientsFindResp) StatusCode() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
type ClientsSearchResp struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
JSON200 *ClientsFindResponse
|
||||
}
|
||||
|
||||
// Status returns HTTPResponse.Status
|
||||
func (r ClientsSearchResp) Status() string {
|
||||
if r.HTTPResponse != nil {
|
||||
return r.HTTPResponse.Status
|
||||
}
|
||||
return http.StatusText(0)
|
||||
}
|
||||
|
||||
// StatusCode returns HTTPResponse.StatusCode
|
||||
func (r ClientsSearchResp) StatusCode() int {
|
||||
if r.HTTPResponse != nil {
|
||||
return r.HTTPResponse.StatusCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ClientsUpdateResp struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
@@ -8098,6 +8231,23 @@ func (c *ClientWithResponses) ClientsFindWithResponse(ctx context.Context, param
|
||||
return ParseClientsFindResp(rsp)
|
||||
}
|
||||
|
||||
// ClientsSearchWithBodyWithResponse request with arbitrary body returning *ClientsSearchResp
|
||||
func (c *ClientWithResponses) ClientsSearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsSearchResp, error) {
|
||||
rsp, err := c.ClientsSearchWithBody(ctx, contentType, body, reqEditors...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ParseClientsSearchResp(rsp)
|
||||
}
|
||||
|
||||
func (c *ClientWithResponses) ClientsSearchWithResponse(ctx context.Context, body ClientsSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsSearchResp, error) {
|
||||
rsp, err := c.ClientsSearch(ctx, body, reqEditors...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ParseClientsSearchResp(rsp)
|
||||
}
|
||||
|
||||
// ClientsUpdateWithBodyWithResponse request with arbitrary body returning *ClientsUpdateResp
|
||||
func (c *ClientWithResponses) ClientsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error) {
|
||||
rsp, err := c.ClientsUpdateWithBody(ctx, contentType, body, reqEditors...)
|
||||
@@ -9243,6 +9393,32 @@ func ParseClientsFindResp(rsp *http.Response) (*ClientsFindResp, error) {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// ParseClientsSearchResp parses an HTTP response from a ClientsSearchWithResponse call
|
||||
func ParseClientsSearchResp(rsp *http.Response) (*ClientsSearchResp, error) {
|
||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||
defer func() { _ = rsp.Body.Close() }()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := &ClientsSearchResp{
|
||||
Body: bodyBytes,
|
||||
HTTPResponse: rsp,
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
||||
var dest ClientsFindResponse
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.JSON200 = &dest
|
||||
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// ParseClientsUpdateResp parses an HTTP response from a ClientsUpdateWithResponse call
|
||||
func ParseClientsUpdateResp(rsp *http.Response) (*ClientsUpdateResp, error) {
|
||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||
|
||||
@@ -242,7 +242,10 @@ var _ = Describe("Types", func() {
|
||||
})
|
||||
It("should return 3 one replicas if urls are different", func() {
|
||||
cfg.Replica = &types.AdGuardInstance{URL: url, APIPath: apiPath}
|
||||
cfg.Replicas = []types.AdGuardInstance{{URL: url + "1", APIPath: apiPath}, {URL: url, APIPath: apiPath + "1"}}
|
||||
cfg.Replicas = []types.AdGuardInstance{
|
||||
{URL: url + "1", APIPath: apiPath},
|
||||
{URL: url, APIPath: apiPath + "1"},
|
||||
}
|
||||
r := cfg.UniqueReplicas()
|
||||
Ω(r).Should(HaveLen(3))
|
||||
})
|
||||
@@ -303,6 +306,29 @@ var _ = Describe("Types", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("Client", func() {
|
||||
Context("Equals", func() {
|
||||
var (
|
||||
cl1 *model.Client
|
||||
cl2 *model.Client
|
||||
)
|
||||
BeforeEach(func() {
|
||||
cl1 = &model.Client{
|
||||
Name: utils.Ptr("foo"),
|
||||
BlockedServicesSchedule: &model.Schedule{TimeZone: utils.Ptr("UTC")},
|
||||
}
|
||||
cl2 = &model.Client{
|
||||
Name: utils.Ptr("foo"),
|
||||
BlockedServicesSchedule: &model.Schedule{TimeZone: utils.Ptr("Local")},
|
||||
}
|
||||
})
|
||||
|
||||
It("should equal if only timezone differs on empty blocked service schedule", func() {
|
||||
Ω(cl1.Equals(cl2)).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
Context("BlockedServices", func() {
|
||||
Context("Equals", func() {
|
||||
It("should be equal", func() {
|
||||
|
||||
175
pkg/config/config-schema.json
Normal file
175
pkg/config/config-schema.json
Normal file
@@ -0,0 +1,175 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"Instance": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"apiPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"autoSetup": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cookie": {
|
||||
"type": "string"
|
||||
},
|
||||
"dhcpServerEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"insecureSkipVerify": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"interfaceName": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"format": "uri",
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"webURL": {
|
||||
"format": "uri",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"description": "validates only for valid schema. No required fields, as the can be defined via env ars afterwards.",
|
||||
"properties": {
|
||||
"api": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"darkMode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"metrics": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"queryLogLimit": {
|
||||
"type": "integer"
|
||||
},
|
||||
"scrapeInterval": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"port": {
|
||||
"type": "number"
|
||||
},
|
||||
"tls": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"certDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"certName": {
|
||||
"type": "string"
|
||||
},
|
||||
"keyName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"continueOnError": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cron": {
|
||||
"type": "string"
|
||||
},
|
||||
"features": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"clientSettings": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"dhcp": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"serverConfig": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"staticLeases": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"dns": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"accessLists": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"rewrites": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"serverConfig": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"filters": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"generalSettings": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"queryLogConfig": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"services": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"statsConfig": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"theme": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"origin": {
|
||||
"$ref": "#/definitions/Instance"
|
||||
},
|
||||
"printConfigOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"replica": {
|
||||
"$ref": "#/definitions/Instance"
|
||||
},
|
||||
"replicas": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/Instance"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"runOnStart": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"title": "adguardhome-sync Configuration",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/log"
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
"github.com/caarlos0/env/v10"
|
||||
"github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -14,16 +14,39 @@ var (
|
||||
logger = log.GetLogger("config")
|
||||
)
|
||||
|
||||
func Get(configFile string, flags Flags) (*types.Config, error) {
|
||||
type AppConfig struct {
|
||||
cfg *types.Config
|
||||
filePath string
|
||||
content string
|
||||
}
|
||||
|
||||
func (ac *AppConfig) PrintConfigOnly() bool {
|
||||
return ac.cfg.PrintConfigOnly
|
||||
}
|
||||
|
||||
func (ac *AppConfig) Get() *types.Config {
|
||||
return ac.cfg
|
||||
}
|
||||
|
||||
func (ac *AppConfig) Init() error {
|
||||
return ac.cfg.Init()
|
||||
}
|
||||
|
||||
func Get(configFile string, flags Flags) (*AppConfig, error) {
|
||||
path, err := configFilePath(configFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = validateSchema(path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cfg := initialConfig()
|
||||
|
||||
// read yaml config
|
||||
if err := readFile(cfg, path); err != nil {
|
||||
var content string
|
||||
if content, err = readFile(cfg, path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,19 +62,26 @@ func Get(configFile string, flags Flags) (*types.Config, error) {
|
||||
replicaDhcpServer := cfg.Replica.DHCPServerEnabled
|
||||
cfg.Replica.DHCPServerEnabled = nil
|
||||
|
||||
// ignore replicas form env parsing as they are handled separately
|
||||
replicas := cfg.Replicas
|
||||
cfg.Replicas = nil
|
||||
|
||||
// overwrite from env vars
|
||||
if err := env.Parse(cfg); err != nil {
|
||||
if err = env.Parse(cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := env.ParseWithOptions(cfg.Replica, env.Options{Prefix: "REPLICA_"}); err != nil {
|
||||
if err = env.ParseWithOptions(cfg.Replica, env.Options{Prefix: "REPLICA_"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// restore the replica
|
||||
cfg.Replicas = replicas
|
||||
|
||||
// if not set from env, use previous value
|
||||
if cfg.Replica.DHCPServerEnabled == nil {
|
||||
cfg.Replica.DHCPServerEnabled = replicaDhcpServer
|
||||
}
|
||||
|
||||
if err := env.ParseWithOptions(&cfg.Origin, env.Options{Prefix: "ORIGIN_"}); err != nil {
|
||||
if err = env.ParseWithOptions(&cfg.Origin, env.Options{Prefix: "ORIGIN_"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -75,7 +105,7 @@ func Get(configFile string, flags Flags) (*types.Config, error) {
|
||||
|
||||
cfg.Replicas, err = enrichReplicasFromEnv(cfg.Replicas)
|
||||
|
||||
return cfg, err
|
||||
return &AppConfig{cfg: cfg, filePath: path, content: content}, err
|
||||
}
|
||||
|
||||
func initialConfig() *types.Config {
|
||||
|
||||
@@ -49,7 +49,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Origin.URL).Should(Equal("https://origin-file:443"))
|
||||
Ω(cfg.Get().Origin.URL).Should(Equal("https://origin-file:443"))
|
||||
})
|
||||
It("should have the origin URL from the config flags", func() {
|
||||
flags.EXPECT().Changed(config.FlagOriginURL).Return(true).AnyTimes()
|
||||
@@ -58,7 +58,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Origin.URL).Should(Equal("https://origin-flag:443"))
|
||||
Ω(cfg.Get().Origin.URL).Should(Equal("https://origin-flag:443"))
|
||||
})
|
||||
It("should have the origin URL from the config env var", func() {
|
||||
setEnv("ORIGIN_URL", "https://origin-env:443")
|
||||
@@ -68,7 +68,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Origin.URL).Should(Equal("https://origin-env:443"))
|
||||
Ω(cfg.Get().Origin.URL).Should(Equal("https://origin-env:443"))
|
||||
})
|
||||
})
|
||||
Context("Replica insecure skip verify", func() {
|
||||
@@ -77,7 +77,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replica.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
})
|
||||
It("should have the insecure skip verify from the config flags", func() {
|
||||
flags.EXPECT().Changed(config.FlagReplicaISV).Return(true).AnyTimes()
|
||||
@@ -86,7 +86,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replica.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InsecureSkipVerify).Should(BeTrue())
|
||||
Ω(cfg.Get().Replicas[0].InsecureSkipVerify).Should(BeTrue())
|
||||
})
|
||||
It("should have the insecure skip verify from the config env var", func() {
|
||||
setEnv("REPLICA_INSECURE_SKIP_VERIFY", "false")
|
||||
@@ -96,7 +96,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replica.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
@@ -106,7 +106,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].InsecureSkipVerify).Should(BeFalse())
|
||||
})
|
||||
It("should have the insecure skip verify from the config env var", func() {
|
||||
setEnv("REPLICA1_INSECURE_SKIP_VERIFY", "true")
|
||||
@@ -114,7 +114,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InsecureSkipVerify).Should(BeTrue())
|
||||
Ω(cfg.Get().Replicas[0].InsecureSkipVerify).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
Context("API Port", func() {
|
||||
@@ -122,7 +122,7 @@ var _ = Describe("Config", func() {
|
||||
flags.EXPECT().Changed(gm.Any()).Return(false).AnyTimes()
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9090))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9090))
|
||||
})
|
||||
It("should have the api port from the config flags", func() {
|
||||
flags.EXPECT().Changed(config.FlagApiPort).Return(true).AnyTimes()
|
||||
@@ -131,7 +131,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9990))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9990))
|
||||
})
|
||||
It("should have the api port from the config env var", func() {
|
||||
setEnv("API_PORT", "9999")
|
||||
@@ -141,7 +141,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9999))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9999))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -151,8 +151,8 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replica.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Get().Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
@@ -162,8 +162,8 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Get().Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
Context("API Port", func() {
|
||||
@@ -171,7 +171,7 @@ var _ = Describe("Config", func() {
|
||||
flags.EXPECT().Changed(gm.Any()).Return(false).AnyTimes()
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9090))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9090))
|
||||
})
|
||||
It("should have the api port from the config flags", func() {
|
||||
flags.EXPECT().Changed(config.FlagApiPort).Return(true).AnyTimes()
|
||||
@@ -180,7 +180,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9990))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9990))
|
||||
})
|
||||
It("should have the api port from the config env var", func() {
|
||||
setEnv("API_PORT", "9999")
|
||||
@@ -190,18 +190,16 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.API.Port).Should(Equal(9999))
|
||||
Ω(cfg.Get().API.Port).Should(Equal(9999))
|
||||
})
|
||||
})
|
||||
|
||||
//////
|
||||
|
||||
Context("Feature DNS Server Config", func() {
|
||||
It("should have the feature dns server config from the config file", func() {
|
||||
flags.EXPECT().Changed(gm.Any()).Return(false).AnyTimes()
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Features.DNS.ServerConfig).Should(BeFalse())
|
||||
Ω(cfg.Get().Features.DNS.ServerConfig).Should(BeFalse())
|
||||
})
|
||||
It("should have the feature dns server config from the config flags", func() {
|
||||
flags.EXPECT().Changed(config.FlagFeatureDnsServerConfig).Return(true).AnyTimes()
|
||||
@@ -210,7 +208,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Features.DNS.ServerConfig).Should(BeTrue())
|
||||
Ω(cfg.Get().Features.DNS.ServerConfig).Should(BeTrue())
|
||||
})
|
||||
It("should have the feature dns server config from the config env var", func() {
|
||||
setEnv("FEATURES_DNS_SERVER_CONFIG", "false")
|
||||
@@ -220,7 +218,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Features.DNS.ServerConfig).Should(BeFalse())
|
||||
Ω(cfg.Get().Features.DNS.ServerConfig).Should(BeFalse())
|
||||
})
|
||||
It("should have the feature dns server config from the config DEPRECATED env var", func() {
|
||||
setEnv("FEATURES_DNS_SERVERCONFIG", "false")
|
||||
@@ -230,7 +228,7 @@ var _ = Describe("Config", func() {
|
||||
|
||||
cfg, err := config.Get("../../testdata/config_test_replicas.yaml", flags)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Features.DNS.ServerConfig).Should(BeFalse())
|
||||
Ω(cfg.Get().Features.DNS.ServerConfig).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/config"
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -17,6 +16,7 @@ var envVars = []string{
|
||||
"FEATURES_CLIENT_SETTINGS",
|
||||
"FEATURES_SERVICES",
|
||||
"FEATURES_FILTERS",
|
||||
"FEATURES_THEME",
|
||||
"FEATURES_DHCP_SERVER_CONFIG",
|
||||
"FEATURES_DHCP_STATIC_LEASES",
|
||||
"FEATURES_DNS_SERVER_CONFIG",
|
||||
@@ -98,7 +98,7 @@ var _ = Describe("Config", func() {
|
||||
Ω(os.Setenv(fmt.Sprintf("REPLICA%s_INTERFACE_NAME", "1"), "eth0")).ShouldNot(HaveOccurred())
|
||||
cfg, err := config.Get("", nil)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].InterfaceName).Should(Equal("eth0"))
|
||||
Ω(cfg.Get().Replicas[0].InterfaceName).Should(Equal("eth0"))
|
||||
})
|
||||
})
|
||||
Context("dhcp server", func() {
|
||||
@@ -107,32 +107,32 @@ var _ = Describe("Config", func() {
|
||||
Ω(os.Setenv(fmt.Sprintf("REPLICA%s_DHCPSERVERENABLED", "1"), "true")).ShouldNot(HaveOccurred())
|
||||
cfg, err := config.Get("", nil)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Replicas[0].DHCPServerEnabled).Should(BeTrue())
|
||||
Ω(cfg.Get().Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Get().Replicas[0].DHCPServerEnabled).Should(BeTrue())
|
||||
})
|
||||
It("should disable the dhcp server of replica 1", func() {
|
||||
Ω(os.Setenv("REPLICA1_URL", "https://foo.bar")).ShouldNot(HaveOccurred())
|
||||
Ω(os.Setenv(fmt.Sprintf("REPLICA%s_DHCPSERVERENABLED", "1"), "false")).ShouldNot(HaveOccurred())
|
||||
cfg, err := config.Get("", nil)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(cfg.Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
Ω(cfg.Get().Replicas[0].DHCPServerEnabled).ShouldNot(BeNil())
|
||||
Ω(*cfg.Get().Replicas[0].DHCPServerEnabled).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func verifyFeatures(cfg *types.Config, value bool) {
|
||||
Ω(cfg.Features.GeneralSettings).Should(Equal(value))
|
||||
Ω(cfg.Features.QueryLogConfig).Should(Equal(value))
|
||||
Ω(cfg.Features.StatsConfig).Should(Equal(value))
|
||||
Ω(cfg.Features.ClientSettings).Should(Equal(value))
|
||||
Ω(cfg.Features.Services).Should(Equal(value))
|
||||
Ω(cfg.Features.Filters).Should(Equal(value))
|
||||
Ω(cfg.Features.DHCP.ServerConfig).Should(Equal(value))
|
||||
Ω(cfg.Features.DHCP.StaticLeases).Should(Equal(value))
|
||||
Ω(cfg.Features.DNS.ServerConfig).Should(Equal(value))
|
||||
Ω(cfg.Features.DNS.AccessLists).Should(Equal(value))
|
||||
Ω(cfg.Features.DNS.Rewrites).Should(Equal(value))
|
||||
func verifyFeatures(cfg *config.AppConfig, value bool) {
|
||||
Ω(cfg.Get().Features.GeneralSettings).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.QueryLogConfig).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.StatsConfig).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.ClientSettings).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.Services).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.Filters).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.DHCP.ServerConfig).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.DHCP.StaticLeases).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.DNS.ServerConfig).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.DNS.AccessLists).Should(Equal(value))
|
||||
Ω(cfg.Get().Features.DNS.Rewrites).Should(Equal(value))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
"github.com/bakito/adguardhome-sync/pkg/utils"
|
||||
"github.com/caarlos0/env/v10"
|
||||
"github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
func handleDeprecatedEnvVars(cfg *types.Config) {
|
||||
|
||||
@@ -8,17 +8,19 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func readFile(cfg *types.Config, path string) error {
|
||||
func readFile(cfg *types.Config, path string) (string, error) {
|
||||
var content string
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
content = string(b)
|
||||
if err := yaml.Unmarshal(b, cfg); err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return content, nil
|
||||
}
|
||||
|
||||
func configFilePath(configFile string) (string, error) {
|
||||
|
||||
90
pkg/config/print-config.go
Normal file
90
pkg/config/print-config.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/client"
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
"github.com/bakito/adguardhome-sync/version"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
//go:embed print-config.md
|
||||
var printConfigTemplate string
|
||||
|
||||
func (ac *AppConfig) Print() error {
|
||||
originVersion := aghVersion(ac.cfg.Origin)
|
||||
var replicaVersions []string
|
||||
for _, replica := range ac.cfg.Replicas {
|
||||
replicaVersions = append(replicaVersions, aghVersion(replica))
|
||||
}
|
||||
|
||||
out, err := ac.print(os.Environ(), originVersion, replicaVersions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Infof(
|
||||
"Printing adguardhome-sync aggregated config (THE APPLICATION WILL NOT START IN THIS MODE):\n%s",
|
||||
out,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func aghVersion(i types.AdGuardInstance) string {
|
||||
cl, err := client.New(i)
|
||||
if err != nil {
|
||||
return "N/A"
|
||||
}
|
||||
stats, err := cl.Status()
|
||||
if err != nil {
|
||||
return "N/A"
|
||||
}
|
||||
return stats.Version
|
||||
}
|
||||
|
||||
func (ac *AppConfig) print(env []string, originVersion string, replicaVersions []string) (string, error) {
|
||||
config, err := yaml.Marshal(ac.Get())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
// The name "inc" is what the function will be called in the template text.
|
||||
"inc": func(i int) int {
|
||||
return i + 1
|
||||
},
|
||||
}
|
||||
|
||||
t, err := template.New("printConfigTemplate").Funcs(funcMap).Parse(printConfigTemplate)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
sort.Strings(env)
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
if err = t.Execute(&buf, map[string]interface{}{
|
||||
"Version": version.Version,
|
||||
"Build": version.Build,
|
||||
"OperatingSystem": runtime.GOOS,
|
||||
"Architecture": runtime.GOARCH,
|
||||
"AggregatedConfig": string(config),
|
||||
"ConfigFilePath": ac.filePath,
|
||||
"ConfigFileContent": ac.content,
|
||||
"EnvironmentVariables": strings.Join(env, "\n"),
|
||||
"OriginVersion": originVersion,
|
||||
"ReplicaVersions": replicaVersions,
|
||||
}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return buf.String(), nil
|
||||
}
|
||||
36
pkg/config/print-config.md
Normal file
36
pkg/config/print-config.md
Normal file
@@ -0,0 +1,36 @@
|
||||
<!-- PLEASE COPY THE FOLLOWING OUTPUT AS IS INTO THE GITHUB ISSUE (Don't forget to mask your usernames, passwords, IPs and other sensitive information when using this in an issue ) -->
|
||||
|
||||
### Runtime
|
||||
|
||||
AdguardHome-Sync Version: {{ .Version }}
|
||||
Build: {{ .Build }}
|
||||
OperatingSystem: {{ .OperatingSystem }}
|
||||
Architecture: {{ .Architecture }}
|
||||
OriginVersion: {{ .OriginVersion }}
|
||||
ReplicaVersions:
|
||||
{{- range $i,$rep := .ReplicaVersions }}
|
||||
- Replica {{ inc $i }}: {{ $rep }}
|
||||
{{- end }}
|
||||
|
||||
### AdGuardHome sync aggregated config
|
||||
|
||||
```yaml
|
||||
{{ .AggregatedConfig }}
|
||||
```
|
||||
{{- if .ConfigFilePath }}
|
||||
### AdGuardHome sync unmodified config file
|
||||
|
||||
Config file path: {{ .ConfigFilePath }}
|
||||
|
||||
```yaml
|
||||
{{ .ConfigFileContent }}
|
||||
```
|
||||
{{- end }}
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```ini
|
||||
{{ .EnvironmentVariables }}
|
||||
```
|
||||
|
||||
<!-- END OF GITHUB ISSUE CONTENT -->
|
||||
58
pkg/config/print-config_test.go
Normal file
58
pkg/config/print-config_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
"github.com/bakito/adguardhome-sync/version"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("AppConfig", func() {
|
||||
var (
|
||||
ac *AppConfig
|
||||
env []string
|
||||
)
|
||||
BeforeEach(func() {
|
||||
ac = &AppConfig{
|
||||
cfg: &types.Config{
|
||||
Origin: types.AdGuardInstance{
|
||||
URL: "https://ha.xxxx.net:3000",
|
||||
},
|
||||
},
|
||||
content: `
|
||||
origin:
|
||||
url: https://ha.xxxx.net:3000
|
||||
`,
|
||||
}
|
||||
env = []string{"FOO=foo", "BAR=bar"}
|
||||
})
|
||||
Context("print", func() {
|
||||
It("should print config without file", func() {
|
||||
out, err := ac.print(env, "v0.0.1", []string{"v0.0.2"})
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(
|
||||
out,
|
||||
).Should(Equal(fmt.Sprintf(expected(1), version.Version, version.Build, runtime.GOOS, runtime.GOARCH)))
|
||||
})
|
||||
It("should print config with file", func() {
|
||||
ac.filePath = "config.yaml"
|
||||
out, err := ac.print(env, "v0.0.1", []string{"v0.0.2"})
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(
|
||||
out,
|
||||
).Should(Equal(fmt.Sprintf(expected(2), version.Version, version.Build, runtime.GOOS, runtime.GOARCH)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func expected(id int) string {
|
||||
b, err := os.ReadFile(filepath.Join("../../testdata/config", fmt.Sprintf("print-config_test_expected%d.md", id)))
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
return string(b)
|
||||
}
|
||||
52
pkg/config/validate.go
Normal file
52
pkg/config/validate.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/santhosh-tekuri/jsonschema/v6"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const schemaURL = "config-schema.json"
|
||||
|
||||
//go:embed config-schema.json
|
||||
var schemaData string
|
||||
|
||||
func validateSchema(cfgFile string) error {
|
||||
// ignore if file not exists
|
||||
if _, err := os.Stat(cfgFile); err != nil {
|
||||
return nil
|
||||
}
|
||||
// Load YAML file
|
||||
yamlContent, err := os.ReadFile(cfgFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return validateYAML(yamlContent)
|
||||
}
|
||||
|
||||
func validateYAML(yamlContent []byte) error {
|
||||
// Convert YAML to JSON
|
||||
var yamlData interface{}
|
||||
err := yaml.Unmarshal(yamlContent, &yamlData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Load JSON schema
|
||||
sch, err := jsonschema.UnmarshalJSON(strings.NewReader(schemaData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := jsonschema.NewCompiler()
|
||||
if err := c.AddResource(schemaURL, sch); err != nil {
|
||||
return err
|
||||
}
|
||||
schema := c.MustCompile(schemaURL)
|
||||
// validateSchema
|
||||
return schema.Validate(yamlData)
|
||||
}
|
||||
39
pkg/config/validate_test.go
Normal file
39
pkg/config/validate_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/bakito/adguardhome-sync/pkg/types"
|
||||
"github.com/go-faker/faker/v4"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var _ = Describe("Config", func() {
|
||||
Context("validateSchema", func() {
|
||||
DescribeTable("validateSchema config",
|
||||
func(configFile string, expectFail bool) {
|
||||
err := validateSchema(configFile)
|
||||
if expectFail {
|
||||
Ω(err).Should(HaveOccurred())
|
||||
} else {
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
}
|
||||
},
|
||||
Entry(`Should be valid`, "../../testdata/config/config-valid.yaml", false),
|
||||
Entry(`Should be valid if file doesn't exist`, "../../testdata/config/foo.bar", false),
|
||||
Entry(`Should fail if file is not yaml`, "../../go.mod", true),
|
||||
)
|
||||
It("validate config with all fields randomly populated", func() {
|
||||
cfg := &types.Config{}
|
||||
|
||||
err := faker.FakeData(cfg)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
data, err := yaml.Marshal(&cfg)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
err = validateYAML(data)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -106,6 +106,11 @@ func Logs() []string {
|
||||
return logs
|
||||
}
|
||||
|
||||
// Clear the current logs
|
||||
func Clear() {
|
||||
logs = nil
|
||||
}
|
||||
|
||||
func addFields(enc zapcore.ObjectEncoder, fields []zapcore.Field) {
|
||||
for i := range fields {
|
||||
fields[i].AddTo(enc)
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"github.com/bakito/adguardhome-sync/pkg/client/model"
|
||||
"github.com/bakito/adguardhome-sync/pkg/log"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
const StatsTotal = "total"
|
||||
|
||||
var (
|
||||
l = log.GetLogger("metrics")
|
||||
|
||||
@@ -129,6 +130,8 @@ var (
|
||||
},
|
||||
[]string{"hostname"},
|
||||
)
|
||||
|
||||
stats = OverallStats{}
|
||||
)
|
||||
|
||||
// Init initializes all Prometheus metrics made available by AdGuard exporter.
|
||||
@@ -152,9 +155,10 @@ func initMetric(name string, metric *prometheus.GaugeVec) {
|
||||
l.With("name", name).Info("New Prometheus metric registered")
|
||||
}
|
||||
|
||||
func Update(ims ...InstanceMetrics) {
|
||||
for _, im := range ims {
|
||||
func Update(iml InstanceMetricsList) {
|
||||
for _, im := range iml.Metrics {
|
||||
update(im)
|
||||
stats[im.HostName] = im.Stats
|
||||
}
|
||||
|
||||
l.Debug("updated")
|
||||
@@ -226,6 +230,10 @@ func update(im InstanceMetrics) {
|
||||
}
|
||||
}
|
||||
|
||||
type InstanceMetricsList struct {
|
||||
Metrics []InstanceMetrics `faker:"slice_len=5"`
|
||||
}
|
||||
|
||||
type InstanceMetrics struct {
|
||||
HostName string
|
||||
Status *model.ServerStatus
|
||||
@@ -233,13 +241,28 @@ type InstanceMetrics struct {
|
||||
QueryLog *model.QueryLog
|
||||
}
|
||||
|
||||
func safeMetric[T Number](v *T) float64 {
|
||||
type OverallStats map[string]*model.Stats
|
||||
|
||||
func (os OverallStats) consolidate() OverallStats {
|
||||
consolidated := OverallStats{StatsTotal: model.NewStats()}
|
||||
for host, stats := range os {
|
||||
consolidated[host] = stats
|
||||
consolidated[StatsTotal].Add(stats)
|
||||
}
|
||||
return consolidated
|
||||
}
|
||||
|
||||
func safeMetric[T int | float64 | float32](v *T) float64 {
|
||||
if v == nil {
|
||||
return 0
|
||||
}
|
||||
return float64(*v)
|
||||
}
|
||||
|
||||
type Number interface {
|
||||
constraints.Float | constraints.Integer
|
||||
func getStats() OverallStats {
|
||||
return stats.consolidate()
|
||||
}
|
||||
|
||||
func (os OverallStats) Total() *model.Stats {
|
||||
return os[StatsTotal]
|
||||
}
|
||||
|
||||
13
pkg/metrics/metrics_suite_test.go
Normal file
13
pkg/metrics/metrics_suite_test.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package metrics_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestSync(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Metrics Suite")
|
||||
}
|
||||
101
pkg/metrics/metrics_test.go
Normal file
101
pkg/metrics/metrics_test.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/bakito/adguardhome-sync/pkg/client/model"
|
||||
"github.com/go-faker/faker/v4"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
var _ = Describe("Metrics", func() {
|
||||
BeforeEach(func() {
|
||||
stats = make(OverallStats)
|
||||
})
|
||||
Context("Update / getStats", func() {
|
||||
It("generate correct stats", func() {
|
||||
Update(InstanceMetricsList{[]InstanceMetrics{
|
||||
{HostName: "foo", Status: &model.ServerStatus{}, Stats: &model.Stats{
|
||||
NumDnsQueries: ptr.To(100),
|
||||
DnsQueries: ptr.To(
|
||||
[]int{10, 20, 30, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
),
|
||||
}},
|
||||
{HostName: "bar", Status: &model.ServerStatus{}, Stats: &model.Stats{
|
||||
NumDnsQueries: ptr.To(200),
|
||||
DnsQueries: ptr.To(
|
||||
[]int{20, 40, 60, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
),
|
||||
}},
|
||||
{HostName: "aaa", Status: &model.ServerStatus{}, Stats: &model.Stats{
|
||||
NumDnsQueries: ptr.To(300),
|
||||
DnsQueries: ptr.To(
|
||||
[]int{30, 60, 90, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
),
|
||||
}},
|
||||
}})
|
||||
Ω(stats).Should(HaveKey("foo"))
|
||||
Ω(stats["foo"].NumDnsQueries).Should(Equal(ptr.To(100)))
|
||||
Ω(stats).Should(HaveKey("bar"))
|
||||
Ω(stats["bar"].NumDnsQueries).Should(Equal(ptr.To(200)))
|
||||
Ω(stats).Should(HaveKey("aaa"))
|
||||
Ω(stats["aaa"].NumDnsQueries).Should(Equal(ptr.To(300)))
|
||||
|
||||
os := getStats()
|
||||
tot := os.Total()
|
||||
Ω(*tot.NumDnsQueries).Should(Equal(600))
|
||||
Ω(
|
||||
*tot.DnsQueries,
|
||||
).Should(Equal([]int{60, 120, 180, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}))
|
||||
|
||||
foo := os["foo"]
|
||||
bar := os["bar"]
|
||||
aaa := os["aaa"]
|
||||
|
||||
Ω(*foo.NumDnsQueries).Should(Equal(100))
|
||||
Ω(*bar.NumDnsQueries).Should(Equal(200))
|
||||
Ω(*aaa.NumDnsQueries).Should(Equal(300))
|
||||
Ω(
|
||||
*foo.DnsQueries,
|
||||
).Should(Equal([]int{10, 20, 30, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}))
|
||||
Ω(
|
||||
*bar.DnsQueries,
|
||||
).Should(Equal([]int{20, 40, 60, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}))
|
||||
Ω(
|
||||
*aaa.DnsQueries,
|
||||
).Should(Equal([]int{30, 60, 90, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}))
|
||||
})
|
||||
})
|
||||
Context("StatsGraph", func() {
|
||||
var metrics InstanceMetricsList
|
||||
BeforeEach(func() {
|
||||
err := faker.FakeData(&metrics)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
It("should provide correct results with faked values", func() {
|
||||
Update(metrics)
|
||||
|
||||
_, dns, blocked, malware, adult := StatsGraph()
|
||||
|
||||
verifyStats(dns)
|
||||
verifyStats(blocked)
|
||||
verifyStats(malware)
|
||||
verifyStats(adult)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func verifyStats(lines []line) {
|
||||
var total line
|
||||
sum := make([]int, len(lines[0].Data))
|
||||
for _, l := range lines {
|
||||
if l.Title == labelTotal {
|
||||
total = l
|
||||
} else {
|
||||
for i, d := range l.Data {
|
||||
sum[i] = sum[i] + d
|
||||
}
|
||||
}
|
||||
}
|
||||
Ω(sum).Should(Equal(total.Data))
|
||||
}
|
||||
130
pkg/metrics/stats.go
Normal file
130
pkg/metrics/stats.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/bakito/adguardhome-sync/pkg/client/model"
|
||||
)
|
||||
|
||||
const labelTotal = "Total"
|
||||
|
||||
var (
|
||||
blue = []int{78, 141, 245}
|
||||
blueAlternatives = [][]int{
|
||||
{44, 95, 163},
|
||||
{122, 166, 247},
|
||||
{30, 61, 92},
|
||||
{93, 158, 255},
|
||||
{58, 123, 213},
|
||||
}
|
||||
|
||||
red = []int{255, 94, 94}
|
||||
redAlternatives = [][]int{
|
||||
{204, 59, 59},
|
||||
{255, 127, 127},
|
||||
{140, 36, 36},
|
||||
{255, 153, 153},
|
||||
{255, 66, 66},
|
||||
}
|
||||
|
||||
yellow = []int{232, 198, 78}
|
||||
yellowAlternatives = [][]int{
|
||||
{196, 163, 60},
|
||||
{255, 220, 110},
|
||||
{140, 114, 36},
|
||||
{250, 233, 156},
|
||||
{212, 180, 84},
|
||||
}
|
||||
|
||||
green = []int{110, 224, 122}
|
||||
greenAlternatives = [][]int{
|
||||
{68, 160, 80},
|
||||
{142, 255, 158},
|
||||
{44, 140, 63},
|
||||
{163, 255, 192},
|
||||
{85, 198, 102},
|
||||
}
|
||||
)
|
||||
|
||||
func StatsGraph() (*model.Stats, []line, []line, []line, []line) {
|
||||
s := getStats()
|
||||
t := s.Total()
|
||||
dns := graphLines(t, s, blue, blueAlternatives, func(s *model.Stats) []int {
|
||||
return safeStats(s.DnsQueries)
|
||||
})
|
||||
blocked := graphLines(t, s, red, redAlternatives, func(s *model.Stats) []int {
|
||||
return safeStats(s.BlockedFiltering)
|
||||
})
|
||||
malware := graphLines(t, s, green, greenAlternatives, func(s *model.Stats) []int {
|
||||
return safeStats(s.ReplacedSafebrowsing)
|
||||
})
|
||||
adult := graphLines(t, s, yellow, yellowAlternatives, func(s *model.Stats) []int {
|
||||
return safeStats(s.ReplacedParental)
|
||||
})
|
||||
|
||||
return t, dns, blocked, malware, adult
|
||||
}
|
||||
|
||||
func safeStats(stats *[]int) []int {
|
||||
if stats == nil {
|
||||
return make([]int, 0)
|
||||
}
|
||||
return *stats
|
||||
}
|
||||
|
||||
func graphLines(
|
||||
t *model.Stats,
|
||||
s OverallStats,
|
||||
baseColor []int,
|
||||
altColors [][]int,
|
||||
dataCB func(s *model.Stats) []int,
|
||||
) []line {
|
||||
g := &graph{
|
||||
total: line{
|
||||
Fill: true,
|
||||
Title: labelTotal,
|
||||
Data: dataCB(t),
|
||||
R: baseColor[0],
|
||||
G: baseColor[1],
|
||||
B: baseColor[2],
|
||||
},
|
||||
}
|
||||
|
||||
var i int
|
||||
for name, data := range s {
|
||||
if name != StatsTotal {
|
||||
g.replicas = append(g.replicas, line{
|
||||
Fill: false,
|
||||
Title: name,
|
||||
Data: dataCB(data),
|
||||
R: altColors[i%len(altColors)][0],
|
||||
G: altColors[i%len(altColors)][1],
|
||||
B: altColors[i%len(altColors)][2],
|
||||
})
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
lines := []line{g.total}
|
||||
|
||||
slices.SortFunc(g.replicas, func(a, b line) int {
|
||||
return strings.Compare(a.Title, b.Title)
|
||||
})
|
||||
lines = append(lines, g.replicas...)
|
||||
return lines
|
||||
}
|
||||
|
||||
type graph struct {
|
||||
total line
|
||||
replicas []line
|
||||
}
|
||||
|
||||
type line struct {
|
||||
Data []int `json:"data"`
|
||||
R int `json:"r"`
|
||||
G int `json:"g"`
|
||||
B int `json:"b"`
|
||||
Title string `json:"title"`
|
||||
Fill bool `json:"fill"`
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
type MockClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockClientMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockClientMockRecorder is the mock recorder for MockClient.
|
||||
@@ -55,52 +56,52 @@ func (mr *MockClientMockRecorder) AccessList() *gomock.Call {
|
||||
}
|
||||
|
||||
// AddClient mocks base method.
|
||||
func (m *MockClient) AddClient(arg0 *model.Client) error {
|
||||
func (m *MockClient) AddClient(client *model.Client) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddClient", arg0)
|
||||
ret := m.ctrl.Call(m, "AddClient", client)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddClient indicates an expected call of AddClient.
|
||||
func (mr *MockClientMockRecorder) AddClient(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) AddClient(client any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddClient", reflect.TypeOf((*MockClient)(nil).AddClient), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddClient", reflect.TypeOf((*MockClient)(nil).AddClient), client)
|
||||
}
|
||||
|
||||
// AddDHCPStaticLease mocks base method.
|
||||
func (m *MockClient) AddDHCPStaticLease(arg0 model.DhcpStaticLease) error {
|
||||
func (m *MockClient) AddDHCPStaticLease(lease model.DhcpStaticLease) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddDHCPStaticLease", arg0)
|
||||
ret := m.ctrl.Call(m, "AddDHCPStaticLease", lease)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddDHCPStaticLease indicates an expected call of AddDHCPStaticLease.
|
||||
func (mr *MockClientMockRecorder) AddDHCPStaticLease(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) AddDHCPStaticLease(lease any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddDHCPStaticLease", reflect.TypeOf((*MockClient)(nil).AddDHCPStaticLease), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddDHCPStaticLease", reflect.TypeOf((*MockClient)(nil).AddDHCPStaticLease), lease)
|
||||
}
|
||||
|
||||
// AddFilter mocks base method.
|
||||
func (m *MockClient) AddFilter(arg0 bool, arg1 model.Filter) error {
|
||||
func (m *MockClient) AddFilter(whitelist bool, f model.Filter) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddFilter", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "AddFilter", whitelist, f)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddFilter indicates an expected call of AddFilter.
|
||||
func (mr *MockClientMockRecorder) AddFilter(arg0, arg1 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) AddFilter(whitelist, f any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddFilter", reflect.TypeOf((*MockClient)(nil).AddFilter), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddFilter", reflect.TypeOf((*MockClient)(nil).AddFilter), whitelist, f)
|
||||
}
|
||||
|
||||
// AddRewriteEntries mocks base method.
|
||||
func (m *MockClient) AddRewriteEntries(arg0 ...model.RewriteEntry) error {
|
||||
func (m *MockClient) AddRewriteEntries(e ...model.RewriteEntry) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{}
|
||||
for _, a := range arg0 {
|
||||
for _, a := range e {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "AddRewriteEntries", varargs...)
|
||||
@@ -109,9 +110,9 @@ func (m *MockClient) AddRewriteEntries(arg0 ...model.RewriteEntry) error {
|
||||
}
|
||||
|
||||
// AddRewriteEntries indicates an expected call of AddRewriteEntries.
|
||||
func (mr *MockClientMockRecorder) AddRewriteEntries(arg0 ...any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) AddRewriteEntries(e ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRewriteEntries", reflect.TypeOf((*MockClient)(nil).AddRewriteEntries), arg0...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRewriteEntries", reflect.TypeOf((*MockClient)(nil).AddRewriteEntries), e...)
|
||||
}
|
||||
|
||||
// BlockedServicesSchedule mocks base method.
|
||||
@@ -160,52 +161,52 @@ func (mr *MockClientMockRecorder) DNSConfig() *gomock.Call {
|
||||
}
|
||||
|
||||
// DeleteClient mocks base method.
|
||||
func (m *MockClient) DeleteClient(arg0 *model.Client) error {
|
||||
func (m *MockClient) DeleteClient(client *model.Client) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteClient", arg0)
|
||||
ret := m.ctrl.Call(m, "DeleteClient", client)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteClient indicates an expected call of DeleteClient.
|
||||
func (mr *MockClientMockRecorder) DeleteClient(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) DeleteClient(client any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteClient", reflect.TypeOf((*MockClient)(nil).DeleteClient), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteClient", reflect.TypeOf((*MockClient)(nil).DeleteClient), client)
|
||||
}
|
||||
|
||||
// DeleteDHCPStaticLease mocks base method.
|
||||
func (m *MockClient) DeleteDHCPStaticLease(arg0 model.DhcpStaticLease) error {
|
||||
func (m *MockClient) DeleteDHCPStaticLease(lease model.DhcpStaticLease) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteDHCPStaticLease", arg0)
|
||||
ret := m.ctrl.Call(m, "DeleteDHCPStaticLease", lease)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteDHCPStaticLease indicates an expected call of DeleteDHCPStaticLease.
|
||||
func (mr *MockClientMockRecorder) DeleteDHCPStaticLease(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) DeleteDHCPStaticLease(lease any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPStaticLease", reflect.TypeOf((*MockClient)(nil).DeleteDHCPStaticLease), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPStaticLease", reflect.TypeOf((*MockClient)(nil).DeleteDHCPStaticLease), lease)
|
||||
}
|
||||
|
||||
// DeleteFilter mocks base method.
|
||||
func (m *MockClient) DeleteFilter(arg0 bool, arg1 model.Filter) error {
|
||||
func (m *MockClient) DeleteFilter(whitelist bool, f model.Filter) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteFilter", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "DeleteFilter", whitelist, f)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteFilter indicates an expected call of DeleteFilter.
|
||||
func (mr *MockClientMockRecorder) DeleteFilter(arg0, arg1 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) DeleteFilter(whitelist, f any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFilter", reflect.TypeOf((*MockClient)(nil).DeleteFilter), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFilter", reflect.TypeOf((*MockClient)(nil).DeleteFilter), whitelist, f)
|
||||
}
|
||||
|
||||
// DeleteRewriteEntries mocks base method.
|
||||
func (m *MockClient) DeleteRewriteEntries(arg0 ...model.RewriteEntry) error {
|
||||
func (m *MockClient) DeleteRewriteEntries(e ...model.RewriteEntry) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{}
|
||||
for _, a := range arg0 {
|
||||
for _, a := range e {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "DeleteRewriteEntries", varargs...)
|
||||
@@ -214,9 +215,9 @@ func (m *MockClient) DeleteRewriteEntries(arg0 ...model.RewriteEntry) error {
|
||||
}
|
||||
|
||||
// DeleteRewriteEntries indicates an expected call of DeleteRewriteEntries.
|
||||
func (mr *MockClientMockRecorder) DeleteRewriteEntries(arg0 ...any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) DeleteRewriteEntries(e ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRewriteEntries", reflect.TypeOf((*MockClient)(nil).DeleteRewriteEntries), arg0...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRewriteEntries", reflect.TypeOf((*MockClient)(nil).DeleteRewriteEntries), e...)
|
||||
}
|
||||
|
||||
// DhcpConfig mocks base method.
|
||||
@@ -294,18 +295,18 @@ func (mr *MockClientMockRecorder) ProfileInfo() *gomock.Call {
|
||||
}
|
||||
|
||||
// QueryLog mocks base method.
|
||||
func (m *MockClient) QueryLog(arg0 int) (*model.QueryLog, error) {
|
||||
func (m *MockClient) QueryLog(limit int) (*model.QueryLog, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "QueryLog", arg0)
|
||||
ret := m.ctrl.Call(m, "QueryLog", limit)
|
||||
ret0, _ := ret[0].(*model.QueryLog)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// QueryLog indicates an expected call of QueryLog.
|
||||
func (mr *MockClientMockRecorder) QueryLog(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) QueryLog(limit any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryLog", reflect.TypeOf((*MockClient)(nil).QueryLog), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryLog", reflect.TypeOf((*MockClient)(nil).QueryLog), limit)
|
||||
}
|
||||
|
||||
// QueryLogConfig mocks base method.
|
||||
@@ -324,17 +325,17 @@ func (mr *MockClientMockRecorder) QueryLogConfig() *gomock.Call {
|
||||
}
|
||||
|
||||
// RefreshFilters mocks base method.
|
||||
func (m *MockClient) RefreshFilters(arg0 bool) error {
|
||||
func (m *MockClient) RefreshFilters(whitelist bool) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RefreshFilters", arg0)
|
||||
ret := m.ctrl.Call(m, "RefreshFilters", whitelist)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// RefreshFilters indicates an expected call of RefreshFilters.
|
||||
func (mr *MockClientMockRecorder) RefreshFilters(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) RefreshFilters(whitelist any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshFilters", reflect.TypeOf((*MockClient)(nil).RefreshFilters), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshFilters", reflect.TypeOf((*MockClient)(nil).RefreshFilters), whitelist)
|
||||
}
|
||||
|
||||
// RewriteList mocks base method.
|
||||
@@ -397,31 +398,31 @@ func (mr *MockClientMockRecorder) SetAccessList(arg0 any) *gomock.Call {
|
||||
}
|
||||
|
||||
// SetBlockedServicesSchedule mocks base method.
|
||||
func (m *MockClient) SetBlockedServicesSchedule(arg0 *model.BlockedServicesSchedule) error {
|
||||
func (m *MockClient) SetBlockedServicesSchedule(schedule *model.BlockedServicesSchedule) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetBlockedServicesSchedule", arg0)
|
||||
ret := m.ctrl.Call(m, "SetBlockedServicesSchedule", schedule)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetBlockedServicesSchedule indicates an expected call of SetBlockedServicesSchedule.
|
||||
func (mr *MockClientMockRecorder) SetBlockedServicesSchedule(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) SetBlockedServicesSchedule(schedule any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockedServicesSchedule", reflect.TypeOf((*MockClient)(nil).SetBlockedServicesSchedule), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockedServicesSchedule", reflect.TypeOf((*MockClient)(nil).SetBlockedServicesSchedule), schedule)
|
||||
}
|
||||
|
||||
// SetCustomRules mocks base method.
|
||||
func (m *MockClient) SetCustomRules(arg0 *[]string) error {
|
||||
func (m *MockClient) SetCustomRules(rules *[]string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetCustomRules", arg0)
|
||||
ret := m.ctrl.Call(m, "SetCustomRules", rules)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetCustomRules indicates an expected call of SetCustomRules.
|
||||
func (mr *MockClientMockRecorder) SetCustomRules(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) SetCustomRules(rules any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCustomRules", reflect.TypeOf((*MockClient)(nil).SetCustomRules), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCustomRules", reflect.TypeOf((*MockClient)(nil).SetCustomRules), rules)
|
||||
}
|
||||
|
||||
// SetDNSConfig mocks base method.
|
||||
@@ -453,17 +454,17 @@ func (mr *MockClientMockRecorder) SetDhcpConfig(arg0 any) *gomock.Call {
|
||||
}
|
||||
|
||||
// SetProfileInfo mocks base method.
|
||||
func (m *MockClient) SetProfileInfo(arg0 *model.ProfileInfo) error {
|
||||
func (m *MockClient) SetProfileInfo(settings *model.ProfileInfo) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetProfileInfo", arg0)
|
||||
ret := m.ctrl.Call(m, "SetProfileInfo", settings)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetProfileInfo indicates an expected call of SetProfileInfo.
|
||||
func (mr *MockClientMockRecorder) SetProfileInfo(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) SetProfileInfo(settings any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProfileInfo", reflect.TypeOf((*MockClient)(nil).SetProfileInfo), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProfileInfo", reflect.TypeOf((*MockClient)(nil).SetProfileInfo), settings)
|
||||
}
|
||||
|
||||
// SetQueryLogConfig mocks base method.
|
||||
@@ -481,31 +482,31 @@ func (mr *MockClientMockRecorder) SetQueryLogConfig(arg0 any) *gomock.Call {
|
||||
}
|
||||
|
||||
// SetSafeSearchConfig mocks base method.
|
||||
func (m *MockClient) SetSafeSearchConfig(arg0 *model.SafeSearchConfig) error {
|
||||
func (m *MockClient) SetSafeSearchConfig(settings *model.SafeSearchConfig) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetSafeSearchConfig", arg0)
|
||||
ret := m.ctrl.Call(m, "SetSafeSearchConfig", settings)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetSafeSearchConfig indicates an expected call of SetSafeSearchConfig.
|
||||
func (mr *MockClientMockRecorder) SetSafeSearchConfig(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) SetSafeSearchConfig(settings any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSafeSearchConfig", reflect.TypeOf((*MockClient)(nil).SetSafeSearchConfig), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSafeSearchConfig", reflect.TypeOf((*MockClient)(nil).SetSafeSearchConfig), settings)
|
||||
}
|
||||
|
||||
// SetStatsConfig mocks base method.
|
||||
func (m *MockClient) SetStatsConfig(arg0 *model.GetStatsConfigResponse) error {
|
||||
func (m *MockClient) SetStatsConfig(sc *model.GetStatsConfigResponse) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetStatsConfig", arg0)
|
||||
ret := m.ctrl.Call(m, "SetStatsConfig", sc)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetStatsConfig indicates an expected call of SetStatsConfig.
|
||||
func (mr *MockClientMockRecorder) SetStatsConfig(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) SetStatsConfig(sc any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetStatsConfig", reflect.TypeOf((*MockClient)(nil).SetStatsConfig), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetStatsConfig", reflect.TypeOf((*MockClient)(nil).SetStatsConfig), sc)
|
||||
}
|
||||
|
||||
// Setup mocks base method.
|
||||
@@ -568,85 +569,85 @@ func (mr *MockClientMockRecorder) Status() *gomock.Call {
|
||||
}
|
||||
|
||||
// ToggleFiltering mocks base method.
|
||||
func (m *MockClient) ToggleFiltering(arg0 bool, arg1 int) error {
|
||||
func (m *MockClient) ToggleFiltering(enabled bool, interval int) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ToggleFiltering", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ToggleFiltering", enabled, interval)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ToggleFiltering indicates an expected call of ToggleFiltering.
|
||||
func (mr *MockClientMockRecorder) ToggleFiltering(arg0, arg1 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) ToggleFiltering(enabled, interval any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleFiltering", reflect.TypeOf((*MockClient)(nil).ToggleFiltering), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleFiltering", reflect.TypeOf((*MockClient)(nil).ToggleFiltering), enabled, interval)
|
||||
}
|
||||
|
||||
// ToggleParental mocks base method.
|
||||
func (m *MockClient) ToggleParental(arg0 bool) error {
|
||||
func (m *MockClient) ToggleParental(enable bool) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ToggleParental", arg0)
|
||||
ret := m.ctrl.Call(m, "ToggleParental", enable)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ToggleParental indicates an expected call of ToggleParental.
|
||||
func (mr *MockClientMockRecorder) ToggleParental(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) ToggleParental(enable any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleParental", reflect.TypeOf((*MockClient)(nil).ToggleParental), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleParental", reflect.TypeOf((*MockClient)(nil).ToggleParental), enable)
|
||||
}
|
||||
|
||||
// ToggleProtection mocks base method.
|
||||
func (m *MockClient) ToggleProtection(arg0 bool) error {
|
||||
func (m *MockClient) ToggleProtection(enable bool) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ToggleProtection", arg0)
|
||||
ret := m.ctrl.Call(m, "ToggleProtection", enable)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ToggleProtection indicates an expected call of ToggleProtection.
|
||||
func (mr *MockClientMockRecorder) ToggleProtection(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) ToggleProtection(enable any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleProtection", reflect.TypeOf((*MockClient)(nil).ToggleProtection), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleProtection", reflect.TypeOf((*MockClient)(nil).ToggleProtection), enable)
|
||||
}
|
||||
|
||||
// ToggleSafeBrowsing mocks base method.
|
||||
func (m *MockClient) ToggleSafeBrowsing(arg0 bool) error {
|
||||
func (m *MockClient) ToggleSafeBrowsing(enable bool) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ToggleSafeBrowsing", arg0)
|
||||
ret := m.ctrl.Call(m, "ToggleSafeBrowsing", enable)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ToggleSafeBrowsing indicates an expected call of ToggleSafeBrowsing.
|
||||
func (mr *MockClientMockRecorder) ToggleSafeBrowsing(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) ToggleSafeBrowsing(enable any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleSafeBrowsing", reflect.TypeOf((*MockClient)(nil).ToggleSafeBrowsing), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleSafeBrowsing", reflect.TypeOf((*MockClient)(nil).ToggleSafeBrowsing), enable)
|
||||
}
|
||||
|
||||
// UpdateClient mocks base method.
|
||||
func (m *MockClient) UpdateClient(arg0 *model.Client) error {
|
||||
func (m *MockClient) UpdateClient(client *model.Client) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateClient", arg0)
|
||||
ret := m.ctrl.Call(m, "UpdateClient", client)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateClient indicates an expected call of UpdateClient.
|
||||
func (mr *MockClientMockRecorder) UpdateClient(arg0 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) UpdateClient(client any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateClient", reflect.TypeOf((*MockClient)(nil).UpdateClient), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateClient", reflect.TypeOf((*MockClient)(nil).UpdateClient), client)
|
||||
}
|
||||
|
||||
// UpdateFilter mocks base method.
|
||||
func (m *MockClient) UpdateFilter(arg0 bool, arg1 model.Filter) error {
|
||||
func (m *MockClient) UpdateFilter(whitelist bool, f model.Filter) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateFilter", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "UpdateFilter", whitelist, f)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateFilter indicates an expected call of UpdateFilter.
|
||||
func (mr *MockClientMockRecorder) UpdateFilter(arg0, arg1 any) *gomock.Call {
|
||||
func (mr *MockClientMockRecorder) UpdateFilter(whitelist, f any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateFilter", reflect.TypeOf((*MockClient)(nil).UpdateFilter), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateFilter", reflect.TypeOf((*MockClient)(nil).UpdateFilter), whitelist, f)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
type MockFlags struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockFlagsMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockFlagsMockRecorder is the mock recorder for MockFlags.
|
||||
@@ -39,60 +40,60 @@ func (m *MockFlags) EXPECT() *MockFlagsMockRecorder {
|
||||
}
|
||||
|
||||
// Changed mocks base method.
|
||||
func (m *MockFlags) Changed(arg0 string) bool {
|
||||
func (m *MockFlags) Changed(name string) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Changed", arg0)
|
||||
ret := m.ctrl.Call(m, "Changed", name)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Changed indicates an expected call of Changed.
|
||||
func (mr *MockFlagsMockRecorder) Changed(arg0 any) *gomock.Call {
|
||||
func (mr *MockFlagsMockRecorder) Changed(name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Changed", reflect.TypeOf((*MockFlags)(nil).Changed), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Changed", reflect.TypeOf((*MockFlags)(nil).Changed), name)
|
||||
}
|
||||
|
||||
// GetBool mocks base method.
|
||||
func (m *MockFlags) GetBool(arg0 string) (bool, error) {
|
||||
func (m *MockFlags) GetBool(name string) (bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBool", arg0)
|
||||
ret := m.ctrl.Call(m, "GetBool", name)
|
||||
ret0, _ := ret[0].(bool)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBool indicates an expected call of GetBool.
|
||||
func (mr *MockFlagsMockRecorder) GetBool(arg0 any) *gomock.Call {
|
||||
func (mr *MockFlagsMockRecorder) GetBool(name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBool", reflect.TypeOf((*MockFlags)(nil).GetBool), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBool", reflect.TypeOf((*MockFlags)(nil).GetBool), name)
|
||||
}
|
||||
|
||||
// GetInt mocks base method.
|
||||
func (m *MockFlags) GetInt(arg0 string) (int, error) {
|
||||
func (m *MockFlags) GetInt(name string) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetInt", arg0)
|
||||
ret := m.ctrl.Call(m, "GetInt", name)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetInt indicates an expected call of GetInt.
|
||||
func (mr *MockFlagsMockRecorder) GetInt(arg0 any) *gomock.Call {
|
||||
func (mr *MockFlagsMockRecorder) GetInt(name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInt", reflect.TypeOf((*MockFlags)(nil).GetInt), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInt", reflect.TypeOf((*MockFlags)(nil).GetInt), name)
|
||||
}
|
||||
|
||||
// GetString mocks base method.
|
||||
func (m *MockFlags) GetString(arg0 string) (string, error) {
|
||||
func (m *MockFlags) GetString(name string) (string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetString", arg0)
|
||||
ret := m.ctrl.Call(m, "GetString", name)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetString indicates an expected call of GetString.
|
||||
func (mr *MockFlagsMockRecorder) GetString(arg0 any) *gomock.Call {
|
||||
func (mr *MockFlagsMockRecorder) GetString(name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetString", reflect.TypeOf((*MockFlags)(nil).GetString), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetString", reflect.TypeOf((*MockFlags)(nil).GetString), name)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ var (
|
||||
actionProfileInfo = func(ac *actionContext) error {
|
||||
if pro, err := ac.client.ProfileInfo(); err != nil {
|
||||
return err
|
||||
} else if merged := pro.ShouldSyncFor(ac.origin.profileInfo); merged != nil {
|
||||
} else if merged := pro.ShouldSyncFor(ac.origin.profileInfo, ac.cfg.Features.Theme); merged != nil {
|
||||
return ac.client.SetProfileInfo(merged)
|
||||
}
|
||||
return nil
|
||||
@@ -94,10 +94,10 @@ var (
|
||||
return err
|
||||
}
|
||||
|
||||
if err = syncFilterType(ac.rl, ac.origin.filters.Filters, rf.Filters, false, ac.client, ac.continueOnError); err != nil {
|
||||
if err = syncFilterType(ac.rl, ac.origin.filters.Filters, rf.Filters, false, ac.client, ac.cfg.ContinueOnError); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = syncFilterType(ac.rl, ac.origin.filters.WhitelistFilters, rf.WhitelistFilters, true, ac.client, ac.continueOnError); err != nil {
|
||||
if err = syncFilterType(ac.rl, ac.origin.filters.WhitelistFilters, rf.WhitelistFilters, true, ac.client, ac.cfg.ContinueOnError); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -105,7 +105,8 @@ var (
|
||||
return ac.client.SetCustomRules(ac.origin.filters.UserRules)
|
||||
}
|
||||
|
||||
if ac.origin.filters.Enabled != rf.Enabled || ac.origin.filters.Interval != rf.Interval {
|
||||
if !utils.PtrEquals(ac.origin.filters.Enabled, rf.Enabled) ||
|
||||
!utils.PtrEquals(ac.origin.filters.Interval, rf.Interval) {
|
||||
return ac.client.ToggleFiltering(*ac.origin.filters.Enabled, *ac.origin.filters.Interval)
|
||||
}
|
||||
return nil
|
||||
@@ -133,7 +134,7 @@ var (
|
||||
for _, client := range r {
|
||||
if err := ac.client.DeleteClient(client); err != nil {
|
||||
ac.rl.With("client-name", client.Name, "error", err).Error("error deleting client setting")
|
||||
if !ac.continueOnError {
|
||||
if !ac.cfg.ContinueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -142,7 +143,7 @@ var (
|
||||
for _, client := range a {
|
||||
if err := ac.client.AddClient(client); err != nil {
|
||||
ac.rl.With("client-name", client.Name, "error", err).Error("error adding client setting")
|
||||
if !ac.continueOnError {
|
||||
if !ac.cfg.ContinueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -151,7 +152,7 @@ var (
|
||||
for _, client := range u {
|
||||
if err := ac.client.UpdateClient(client); err != nil {
|
||||
ac.rl.With("client-name", client.Name, "error", err).Error("error updating client setting")
|
||||
if !ac.continueOnError {
|
||||
if !ac.cfg.ContinueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -176,7 +177,7 @@ var (
|
||||
return err
|
||||
}
|
||||
|
||||
dc.Sanitize(ac.rl)
|
||||
// dc.Sanitize(ac.rl)
|
||||
|
||||
if !dc.Equals(ac.origin.dnsConfig) {
|
||||
if err = ac.client.SetDNSConfig(ac.origin.dnsConfig); err != nil {
|
||||
@@ -218,7 +219,7 @@ var (
|
||||
for _, lease := range r {
|
||||
if err := ac.client.DeleteDHCPStaticLease(lease); err != nil {
|
||||
ac.rl.With("hostname", lease.Hostname, "error", err).Error("error deleting dhcp static lease")
|
||||
if !ac.continueOnError {
|
||||
if !ac.cfg.ContinueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -227,7 +228,7 @@ var (
|
||||
for _, lease := range a {
|
||||
if err := ac.client.AddDHCPStaticLease(lease); err != nil {
|
||||
ac.rl.With("hostname", lease.Hostname, "error", err).Error("error adding dhcp static lease")
|
||||
if !ac.continueOnError {
|
||||
if !ac.cfg.ContinueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -236,7 +237,14 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func syncFilterType(rl *zap.SugaredLogger, of *[]model.Filter, rFilters *[]model.Filter, whitelist bool, replica client.Client, continueOnError bool) error {
|
||||
func syncFilterType(
|
||||
rl *zap.SugaredLogger,
|
||||
of *[]model.Filter,
|
||||
rFilters *[]model.Filter,
|
||||
whitelist bool,
|
||||
replica client.Client,
|
||||
continueOnError bool,
|
||||
) error {
|
||||
fa, fu, fd := model.MergeFilters(rFilters, of)
|
||||
|
||||
for _, f := range fd {
|
||||
|
||||
@@ -17,6 +17,11 @@ func setupActions(cfg *types.Config) (actions []syncAction) {
|
||||
action("safe browsing", actionSafeBrowsing),
|
||||
)
|
||||
}
|
||||
if cfg.Features.DNS.ServerConfig {
|
||||
actions = append(actions,
|
||||
action("DNS server config", actionDNSServerConfig),
|
||||
)
|
||||
}
|
||||
if cfg.Features.QueryLogConfig {
|
||||
actions = append(actions,
|
||||
action("query log config", actionQueryLogConfig),
|
||||
@@ -52,12 +57,6 @@ func setupActions(cfg *types.Config) (actions []syncAction) {
|
||||
action("DNS access lists", actionDNSAccessLists),
|
||||
)
|
||||
}
|
||||
|
||||
if cfg.Features.DNS.ServerConfig {
|
||||
actions = append(actions,
|
||||
action("DNS server config", actionDNSServerConfig),
|
||||
)
|
||||
}
|
||||
if cfg.Features.DHCP.ServerConfig {
|
||||
actions = append(actions,
|
||||
action("DHCP server config", actionDHCPServerConfig),
|
||||
@@ -77,12 +76,12 @@ type syncAction interface {
|
||||
}
|
||||
|
||||
type actionContext struct {
|
||||
rl *zap.SugaredLogger
|
||||
origin *origin
|
||||
client client.Client
|
||||
replicaStatus *model.ServerStatus
|
||||
continueOnError bool
|
||||
replica types.AdGuardInstance
|
||||
rl *zap.SugaredLogger
|
||||
origin *origin
|
||||
client client.Client
|
||||
replicaStatus *model.ServerStatus
|
||||
replica types.AdGuardInstance
|
||||
cfg *types.Config
|
||||
}
|
||||
|
||||
type defaultAction struct {
|
||||
|
||||
@@ -33,11 +33,38 @@ func (w *worker) handleSync(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (w *worker) handleRoot(c *gin.Context) {
|
||||
total, dns, blocked, malware, adult := metrics.StatsGraph()
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", map[string]interface{}{
|
||||
"DarkMode": w.cfg.API.DarkMode,
|
||||
"Metrics": w.cfg.API.Metrics.Enabled,
|
||||
"Version": version.Version,
|
||||
"Build": version.Build,
|
||||
"SyncStatus": w.status(),
|
||||
"Stats": map[string]interface{}{
|
||||
"Labels": getLast24Hours(),
|
||||
"DNS": dns,
|
||||
"Blocked": blocked,
|
||||
"BlockedPercentage": fmt.Sprintf(
|
||||
"%.2f",
|
||||
(float64(*total.NumBlockedFiltering)*100.0)/float64(*total.NumDnsQueries),
|
||||
),
|
||||
"Malware": malware,
|
||||
"MalwarePercentage": fmt.Sprintf(
|
||||
"%.2f",
|
||||
(float64(*total.NumReplacedSafebrowsing)*100.0)/float64(*total.NumDnsQueries),
|
||||
),
|
||||
"Adult": adult,
|
||||
"AdultPercentage": fmt.Sprintf(
|
||||
"%.2f",
|
||||
(float64(*total.NumReplacedParental)*100.0)/float64(*total.NumDnsQueries),
|
||||
),
|
||||
|
||||
"TotalDNS": total.NumDnsQueries,
|
||||
"TotalBlocked": total.NumBlockedFiltering,
|
||||
"TotalMalware": total.NumReplacedSafebrowsing,
|
||||
"TotalAdult": total.NumReplacedParental,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -50,12 +77,22 @@ func (w *worker) handleLogs(c *gin.Context) {
|
||||
c.Data(http.StatusOK, "text/plain", []byte(strings.Join(log.Logs(), "")))
|
||||
}
|
||||
|
||||
func (w *worker) handleClearLogs(c *gin.Context) {
|
||||
log.Clear()
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
func (w *worker) handleStatus(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, w.status())
|
||||
}
|
||||
|
||||
func (w *worker) listenAndServe() {
|
||||
l.With("port", w.cfg.API.Port).Info("Starting API server")
|
||||
sl := l.With("port", w.cfg.API.Port)
|
||||
if w.cfg.API.TLS.Enabled() {
|
||||
c, k := w.cfg.API.TLS.Certs()
|
||||
sl = sl.With("tls-cert", c).With("tls-key", k)
|
||||
}
|
||||
sl.Info("Starting API server")
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
@@ -75,6 +112,7 @@ func (w *worker) listenAndServe() {
|
||||
r.SetHTMLTemplate(template.Must(template.New("index.html").Parse(string(index))))
|
||||
r.POST("/api/v1/sync", w.handleSync)
|
||||
r.GET("/api/v1/logs", w.handleLogs)
|
||||
r.POST("/api/v1/clear-logs", w.handleClearLogs)
|
||||
r.GET("/api/v1/status", w.handleStatus)
|
||||
r.GET("/favicon.ico", w.handleFavicon)
|
||||
r.GET("/", w.handleRoot)
|
||||
@@ -85,7 +123,14 @@ func (w *worker) listenAndServe() {
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := httpServer.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
|
||||
var err error
|
||||
if w.cfg.API.TLS.Enabled() {
|
||||
err = httpServer.ListenAndServeTLS(w.cfg.API.TLS.Certs())
|
||||
} else {
|
||||
err = httpServer.ListenAndServe()
|
||||
}
|
||||
|
||||
if !errors.Is(err, http.ErrServerClosed) {
|
||||
l.With("error", err).Fatalf("HTTP server ListenAndServe")
|
||||
}
|
||||
}()
|
||||
@@ -141,3 +186,26 @@ type replicaStatus struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
ProtectionEnabled *bool `json:"protection_enabled"`
|
||||
}
|
||||
|
||||
func getLast24Hours() []string {
|
||||
var result []string
|
||||
currentTime := time.Now()
|
||||
|
||||
// Loop to get the last 24 hours
|
||||
for i := 0; i < 24; i++ {
|
||||
// Calculate the time for the current hour in the loop
|
||||
timeInstance := currentTime.Add(time.Duration(-i) * time.Hour)
|
||||
timeInstance = timeInstance.Truncate(time.Hour)
|
||||
|
||||
// Format the time as "14 Dec 17:00"
|
||||
formattedTime := timeInstance.Format("02 Jan 15:04")
|
||||
result = append(result, formattedTime)
|
||||
}
|
||||
|
||||
// Reverse the slice to get the correct order (from oldest to latest)
|
||||
for i, j := 0, len(result)-1; i < j; i, j = i+1, j-1 {
|
||||
result[i], result[j] = result[j], result[i]
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>AdGuardHome sync</title>
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js">
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js">
|
||||
</script>
|
||||
{{- if .DarkMode }}
|
||||
<link rel="stylesheet" href="https://bootswatch.com/5/darkly/bootstrap.min.css"
|
||||
crossorigin="anonymous">
|
||||
{{- else }}
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We"
|
||||
crossOrigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
crossorigin="anonymous">
|
||||
{{- end }}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
@@ -30,6 +30,12 @@
|
||||
}
|
||||
);
|
||||
});
|
||||
$("#clearLogs").click(function () {
|
||||
$.post("api/v1/clear-logs", {}, function () {
|
||||
$('#logs').html("");
|
||||
}
|
||||
);
|
||||
});
|
||||
$("#sync").click(function () {
|
||||
$.post("api/v1/sync", {}, function (data) {
|
||||
});
|
||||
@@ -39,6 +45,43 @@
|
||||
});
|
||||
</script>
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<style>
|
||||
.stat-card {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
height: 100%;
|
||||
}
|
||||
{{- if .Metrics }}
|
||||
.stat-card h3 {
|
||||
margin: 0;
|
||||
font-size: 2rem;
|
||||
}
|
||||
.stat-card p {
|
||||
margin: 5px 0;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.percentage {
|
||||
font-size: 0.9rem;
|
||||
text-align: right;
|
||||
height: 20px;
|
||||
}
|
||||
canvas {
|
||||
flex-grow: 1;
|
||||
height: 100px !important;
|
||||
}
|
||||
{{- end }}
|
||||
.button-row {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.btn-group {
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid px-4">
|
||||
@@ -48,15 +91,60 @@
|
||||
<p class="h6">{{ .Version }} ({{ .Build }})</p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{- if .Metrics }}
|
||||
<div class="row g-4 d-flex">
|
||||
<div class="col-12 col-md-3 d-flex">
|
||||
<div class="stat-card flex-fill">
|
||||
<div class="percentage"></div>
|
||||
<h3 style="color: rgb(78, 141, 245);">{{.Stats.TotalDNS}}</h3>
|
||||
<p>DNS Queries</p>
|
||||
<canvas id="dnsQueriesChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 d-flex">
|
||||
<div class="stat-card flex-fill">
|
||||
<div class="percentage" style="color: rgb(255, 94, 94);">{{.Stats.BlockedPercentage}}%</div>
|
||||
<h3 style="color: rgb(255, 94, 94);">{{.Stats.TotalBlocked}}</h3>
|
||||
<p>Blocked by Filters</p>
|
||||
<canvas id="blockedFiltersChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 d-flex">
|
||||
<div class="stat-card flex-fill">
|
||||
<div class="percentage" style="color: rgb(110, 224, 122);">{{.Stats.MalwarePercentage}}%</div>
|
||||
<h3 style="color: rgb(110, 224, 122);">{{.Stats.TotalMalware}}</h3>
|
||||
<p>Blocked malware/phishing</p>
|
||||
<canvas id="malwareChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 d-flex">
|
||||
<div class="stat-card flex-fill">
|
||||
<div class="percentage" style="color: rgb(232, 198, 78);">{{.Stats.AdultPercentage}}%</div>
|
||||
<h3 style="color: rgb(232, 198, 78);">{{.Stats.TotalAdult}}</h3>
|
||||
<p>Blocked adult websites</p>
|
||||
<canvas id="adultWebsitesChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
||||
<div class="row button-row">
|
||||
<div class="col">
|
||||
<div class="btn-group" role="group">
|
||||
<input class="btn btn-success" type="button" id="sync" value="Synchronize"/>
|
||||
<input class="btn btn-secondary" type="button" id="showLogs" value="Update Logs"/>
|
||||
<button type="button" class="btn btn-success" id="sync">Synchronize</button>
|
||||
<button type="button" class="btn btn-secondary" id="showLogs">Update Logs</button>
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" id="clearLogs">Clear Logs</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-md-auto">
|
||||
<div class="float-right">
|
||||
<div class="btn-group float-right" role="group">
|
||||
<a href="{{ .SyncStatus.Origin.URL }}" target="_blank" class="btn btn-{{ .SyncStatus.Origin.Status }}"
|
||||
type="button" id="origin"
|
||||
{{ if .SyncStatus.Origin.Error }} title="{{ .SyncStatus.Origin.Error }}" {{ end }}>Origin {{ .SyncStatus.Origin.Host }}</a>
|
||||
@@ -69,10 +157,97 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col-12">
|
||||
<pre class="p-3 border"><code id="logs"></code></pre>
|
||||
<div class="col-12 col-md-12">
|
||||
<div class="stat-card">
|
||||
<pre class="p-3 border"><code id="logs"></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- openssl dgst -sha384 -binary popper.min.js | openssl base64 -A -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"
|
||||
integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous">
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"
|
||||
integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous">
|
||||
</script>
|
||||
{{- if .Metrics }}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js"ŝ
|
||||
integrity="sha384-vsrfeLOOY6KuIYKDlmVH5UiBmgIdB1oEf7p01YgWHuqmOHfZr374+odEv96n9tNC" crossorigin="anonymous">
|
||||
</script>
|
||||
<script>
|
||||
// Function to create minimal line charts
|
||||
function createChart(canvasId, data) {
|
||||
const ctx = document.getElementById(canvasId).getContext('2d');
|
||||
|
||||
const datasets = Array(data.length);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
datasets[i] = {
|
||||
data: data[i].data,
|
||||
title: data[i].title,
|
||||
backgroundColor: `rgb(${data[i].r}, ${data[i].g}, ${data[i].b}, 0.2)`,
|
||||
borderColor: `rgb(${data[i].r}, ${data[i].g}, ${data[i].b}, 1)`,
|
||||
borderWidth: 3,
|
||||
fill: data[i].fill,
|
||||
pointRadius: 0,
|
||||
}
|
||||
}
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: {{.Stats.Labels}},
|
||||
datasets: datasets
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
interaction: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
},
|
||||
plugins: {
|
||||
legend: { display: false },
|
||||
tooltip: {
|
||||
enabled: true,
|
||||
bodyFont: {
|
||||
size: 20
|
||||
},
|
||||
titleFont: {
|
||||
size: 20
|
||||
},
|
||||
displayColors: false,
|
||||
callbacks: {
|
||||
label: function(tooltipItem) {
|
||||
if (tooltipItem.dataset.title) {
|
||||
return tooltipItem.raw + " - " + tooltipItem.dataset.title;
|
||||
}
|
||||
return tooltipItem.raw;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
x: { display: false,
|
||||
title: {
|
||||
display: true
|
||||
}
|
||||
},
|
||||
y: { display: false,
|
||||
min: 0,
|
||||
title: {
|
||||
display: true
|
||||
} }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
createChart('dnsQueriesChart', {{.Stats.DNS}});
|
||||
createChart('blockedFiltersChart', {{.Stats.Blocked}});
|
||||
createChart('malwareChart', {{.Stats.Malware}});
|
||||
createChart('adultWebsitesChart', {{.Stats.Adult}});
|
||||
</script>
|
||||
{{- end }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -26,13 +26,13 @@ func (w *worker) startScraping() {
|
||||
}
|
||||
|
||||
func (w *worker) scrape() {
|
||||
var ims []metrics.InstanceMetrics
|
||||
var iml metrics.InstanceMetricsList
|
||||
|
||||
ims = append(ims, w.getMetrics(w.cfg.Origin))
|
||||
iml.Metrics = append(iml.Metrics, w.getMetrics(w.cfg.Origin))
|
||||
for _, replica := range w.cfg.Replicas {
|
||||
ims = append(ims, w.getMetrics(replica))
|
||||
iml.Metrics = append(iml.Metrics, w.getMetrics(replica))
|
||||
}
|
||||
metrics.Update(ims...)
|
||||
metrics.Update(iml)
|
||||
}
|
||||
|
||||
func (w *worker) getMetrics(inst types.AdGuardInstance) (im metrics.InstanceMetrics) {
|
||||
|
||||
@@ -66,16 +66,12 @@ func Sync(cfg *types.Config) error {
|
||||
if cfg.API.Port != 0 {
|
||||
w.cron.Start()
|
||||
} else {
|
||||
runOnStartAsync(cfg, w)
|
||||
w.cron.Run()
|
||||
}
|
||||
}
|
||||
if cfg.API.Port != 0 {
|
||||
if cfg.RunOnStart {
|
||||
go func() {
|
||||
l.Info("Running sync on startup")
|
||||
w.sync()
|
||||
}()
|
||||
}
|
||||
runOnStartAsync(cfg, w)
|
||||
w.listenAndServe()
|
||||
} else if cfg.RunOnStart {
|
||||
l.Info("Running sync on startup")
|
||||
@@ -85,6 +81,15 @@ func Sync(cfg *types.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func runOnStartAsync(cfg *types.Config, w *worker) {
|
||||
if cfg.RunOnStart {
|
||||
go func() {
|
||||
l.Info("Running sync on startup")
|
||||
w.sync()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
type worker struct {
|
||||
cfg *types.Config
|
||||
running bool
|
||||
@@ -167,7 +172,8 @@ func (w *worker) sync() {
|
||||
}
|
||||
|
||||
if versions.IsNewerThan(versions.MinAgh, o.status.Version) {
|
||||
sl.With("error", err, "version", o.status.Version).Errorf("Origin AdGuard Home version must be >= %s", versions.MinAgh)
|
||||
sl.With("error", err, "version", o.status.Version).
|
||||
Errorf("Origin AdGuard Home version must be >= %s", versions.MinAgh)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -275,21 +281,23 @@ func (w *worker) syncTo(l *zap.SugaredLogger, o *origin, replica types.AdGuardIn
|
||||
rl.With("version", replicaStatus.Version).Info("Connected to replica")
|
||||
|
||||
if versions.IsNewerThan(versions.MinAgh, replicaStatus.Version) {
|
||||
rl.With("error", err, "version", replicaStatus.Version).Errorf("Replica AdGuard Home version must be >= %s", versions.MinAgh)
|
||||
rl.With("error", err, "version", replicaStatus.Version).
|
||||
Errorf("Replica AdGuard Home version must be >= %s", versions.MinAgh)
|
||||
return
|
||||
}
|
||||
|
||||
if o.status.Version != replicaStatus.Version {
|
||||
rl.With("originVersion", o.status.Version, "replicaVersion", replicaStatus.Version).Warn("Versions do not match")
|
||||
rl.With("originVersion", o.status.Version, "replicaVersion", replicaStatus.Version).
|
||||
Warn("Versions do not match")
|
||||
}
|
||||
|
||||
ac := &actionContext{
|
||||
continueOnError: w.cfg.ContinueOnError,
|
||||
rl: rl,
|
||||
origin: o,
|
||||
replicaStatus: replicaStatus,
|
||||
client: rc,
|
||||
replica: replica,
|
||||
cfg: w.cfg,
|
||||
rl: rl,
|
||||
origin: o,
|
||||
replicaStatus: replicaStatus,
|
||||
client: rc,
|
||||
replica: replica,
|
||||
}
|
||||
for _, action := range w.actions {
|
||||
if err := action.sync(ac); err != nil {
|
||||
@@ -303,7 +311,11 @@ func (w *worker) syncTo(l *zap.SugaredLogger, o *origin, replica types.AdGuardIn
|
||||
rl.Info("Sync done")
|
||||
}
|
||||
|
||||
func (w *worker) statusWithSetup(rl *zap.SugaredLogger, replica types.AdGuardInstance, rc client.Client) (*model.ServerStatus, error) {
|
||||
func (w *worker) statusWithSetup(
|
||||
rl *zap.SugaredLogger,
|
||||
replica types.AdGuardInstance,
|
||||
rc client.Client,
|
||||
) (*model.ServerStatus, error) {
|
||||
rs, err := rc.Status()
|
||||
if err != nil {
|
||||
if replica.AutoSetup && errors.Is(err, client.ErrSetupNeeded) {
|
||||
|
||||
@@ -48,6 +48,7 @@ var _ = Describe("Sync", func() {
|
||||
GeneralSettings: true,
|
||||
StatsConfig: true,
|
||||
QueryLogConfig: true,
|
||||
Theme: true,
|
||||
},
|
||||
Replicas: []types.AdGuardInstance{
|
||||
{},
|
||||
@@ -57,8 +58,8 @@ var _ = Describe("Sync", func() {
|
||||
te = errors.New(uuid.NewString())
|
||||
|
||||
ac = &actionContext{
|
||||
continueOnError: false,
|
||||
rl: l,
|
||||
cfg: w.cfg,
|
||||
rl: l,
|
||||
origin: &origin{
|
||||
profileInfo: &model.ProfileInfo{
|
||||
Name: "origin",
|
||||
@@ -258,16 +259,32 @@ var _ = Describe("Sync", func() {
|
||||
err := actionProfileInfo(ac)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
It("should not change theme if feature is disabled", func() {
|
||||
ac.origin.profileInfo.Language = "de"
|
||||
ac.cfg.Features.Theme = false
|
||||
cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{Name: "replica", Language: "en"}, nil)
|
||||
cl.EXPECT().SetProfileInfo(&model.ProfileInfo{
|
||||
Language: "de",
|
||||
Name: "replica",
|
||||
Theme: "",
|
||||
})
|
||||
err := actionProfileInfo(ac)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
It("should not sync profileInfo if language is not set", func() {
|
||||
ac.origin.profileInfo.Language = ""
|
||||
cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{Name: "replica", Language: "en", Theme: "auto"}, nil)
|
||||
cl.EXPECT().
|
||||
ProfileInfo().
|
||||
Return(&model.ProfileInfo{Name: "replica", Language: "en", Theme: "auto"}, nil)
|
||||
cl.EXPECT().SetProfileInfo(ac.origin.profileInfo).Times(0)
|
||||
err := actionProfileInfo(ac)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
It("should not sync profileInfo if theme is not set", func() {
|
||||
ac.origin.profileInfo.Theme = ""
|
||||
cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{Name: "replica", Language: "en", Theme: "auto"}, nil)
|
||||
cl.EXPECT().
|
||||
ProfileInfo().
|
||||
Return(&model.ProfileInfo{Name: "replica", Language: "en", Theme: "auto"}, nil)
|
||||
cl.EXPECT().SetProfileInfo(ac.origin.profileInfo).Times(0)
|
||||
err := actionProfileInfo(ac)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
@@ -302,7 +319,8 @@ var _ = Describe("Sync", func() {
|
||||
var interval model.QueryLogConfigInterval = 123
|
||||
ac.origin.queryLogConfig.Interval = &interval
|
||||
cl.EXPECT().QueryLogConfig().Return(qlc, nil)
|
||||
cl.EXPECT().SetQueryLogConfig(&model.QueryLogConfigWithIgnored{QueryLogConfig: model.QueryLogConfig{AnonymizeClientIp: nil, Interval: &interval, Enabled: nil}})
|
||||
cl.EXPECT().
|
||||
SetQueryLogConfig(&model.QueryLogConfigWithIgnored{QueryLogConfig: model.QueryLogConfig{AnonymizeClientIp: nil, Interval: &interval, Enabled: nil}})
|
||||
err := actionQueryLogConfig(ac)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
@@ -421,7 +439,9 @@ var _ = Describe("Sync", func() {
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
It("should update a filter", func() {
|
||||
ac.origin.filters.Filters = utils.Ptr([]model.Filter{{Name: "foo", Url: "https://foo.bar", Enabled: true}})
|
||||
ac.origin.filters.Filters = utils.Ptr(
|
||||
[]model.Filter{{Name: "foo", Url: "https://foo.bar", Enabled: true}},
|
||||
)
|
||||
rf.Filters = utils.Ptr([]model.Filter{{Name: "foo", Url: "https://foo.bar"}})
|
||||
cl.EXPECT().Filtering().Return(rf, nil)
|
||||
cl.EXPECT().UpdateFilter(false, model.Filter{Name: "foo", Url: "https://foo.bar", Enabled: true})
|
||||
@@ -431,19 +451,25 @@ var _ = Describe("Sync", func() {
|
||||
})
|
||||
|
||||
It("should abort after failed added filter", func() {
|
||||
ac.continueOnError = false
|
||||
ac.cfg.ContinueOnError = false
|
||||
ac.origin.filters.Filters = utils.Ptr([]model.Filter{{Name: "foo", Url: "https://foo.bar"}})
|
||||
cl.EXPECT().Filtering().Return(rf, nil)
|
||||
cl.EXPECT().AddFilter(false, model.Filter{Name: "foo", Url: "https://foo.bar"}).Return(errors.New("test failure"))
|
||||
cl.EXPECT().
|
||||
AddFilter(false, model.Filter{Name: "foo", Url: "https://foo.bar"}).
|
||||
Return(errors.New("test failure"))
|
||||
err := actionFilters(ac)
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
|
||||
It("should continue after failed added filter", func() {
|
||||
ac.continueOnError = true
|
||||
ac.origin.filters.Filters = utils.Ptr([]model.Filter{{Name: "foo", Url: "https://foo.bar"}, {Name: "bar", Url: "https://bar.foo"}})
|
||||
ac.cfg.ContinueOnError = true
|
||||
ac.origin.filters.Filters = utils.Ptr(
|
||||
[]model.Filter{{Name: "foo", Url: "https://foo.bar"}, {Name: "bar", Url: "https://bar.foo"}},
|
||||
)
|
||||
cl.EXPECT().Filtering().Return(rf, nil)
|
||||
cl.EXPECT().AddFilter(false, model.Filter{Name: "foo", Url: "https://foo.bar"}).Return(errors.New("test failure"))
|
||||
cl.EXPECT().
|
||||
AddFilter(false, model.Filter{Name: "foo", Url: "https://foo.bar"}).
|
||||
Return(errors.New("test failure"))
|
||||
cl.EXPECT().AddFilter(false, model.Filter{Name: "bar", Url: "https://bar.foo"})
|
||||
cl.EXPECT().RefreshFilters(gm.Any())
|
||||
err := actionFilters(ac)
|
||||
|
||||
@@ -21,19 +21,21 @@ func NewFeatures(enabled bool) Features {
|
||||
ClientSettings: enabled,
|
||||
Services: enabled,
|
||||
Filters: enabled,
|
||||
Theme: enabled,
|
||||
}
|
||||
}
|
||||
|
||||
// Features feature flags
|
||||
type Features struct {
|
||||
DNS DNS `json:"dns" yaml:"dns"`
|
||||
DHCP DHCP `json:"dhcp" yaml:"dhcp"`
|
||||
DNS DNS `json:"dns" yaml:"dns"`
|
||||
DHCP DHCP `json:"dhcp" yaml:"dhcp"`
|
||||
GeneralSettings bool `json:"generalSettings" yaml:"generalSettings" env:"FEATURES_GENERAL_SETTINGS"`
|
||||
QueryLogConfig bool `json:"queryLogConfig" yaml:"queryLogConfig" env:"FEATURES_QUERY_LOG_CONFIG"`
|
||||
StatsConfig bool `json:"statsConfig" yaml:"statsConfig" env:"FEATURES_STATS_CONFIG"`
|
||||
ClientSettings bool `json:"clientSettings" yaml:"clientSettings" env:"FEATURES_CLIENT_SETTINGS"`
|
||||
Services bool `json:"services" yaml:"services" env:"FEATURES_SERVICES"`
|
||||
Filters bool `json:"filters" yaml:"filters" env:"FEATURES_FILTERS"`
|
||||
QueryLogConfig bool `json:"queryLogConfig" yaml:"queryLogConfig" env:"FEATURES_QUERY_LOG_CONFIG"`
|
||||
StatsConfig bool `json:"statsConfig" yaml:"statsConfig" env:"FEATURES_STATS_CONFIG"`
|
||||
ClientSettings bool `json:"clientSettings" yaml:"clientSettings" env:"FEATURES_CLIENT_SETTINGS"`
|
||||
Services bool `json:"services" yaml:"services" env:"FEATURES_SERVICES"`
|
||||
Filters bool `json:"filters" yaml:"filters" env:"FEATURES_FILTERS"`
|
||||
Theme bool `json:"theme" yaml:"theme" env:"FEATURES_THEME"`
|
||||
}
|
||||
|
||||
// DHCP features
|
||||
@@ -44,9 +46,9 @@ type DHCP struct {
|
||||
|
||||
// DNS features
|
||||
type DNS struct {
|
||||
AccessLists bool `json:"accessLists" yaml:"accessLists" env:"FEATURES_DNS_ACCESS_LISTS"`
|
||||
AccessLists bool `json:"accessLists" yaml:"accessLists" env:"FEATURES_DNS_ACCESS_LISTS"`
|
||||
ServerConfig bool `json:"serverConfig" yaml:"serverConfig" env:"FEATURES_DNS_SERVER_CONFIG"`
|
||||
Rewrites bool `json:"rewrites" yaml:"rewrites" env:"FEATURES_DNS_REWRITES"`
|
||||
Rewrites bool `json:"rewrites" yaml:"rewrites" env:"FEATURES_DNS_REWRITES"`
|
||||
}
|
||||
|
||||
// LogDisabled log all disabled features
|
||||
|
||||
@@ -3,6 +3,7 @@ package types
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -17,31 +18,56 @@ const (
|
||||
// Config application configuration struct
|
||||
// +k8s:deepcopy-gen=true
|
||||
type Config struct {
|
||||
Origin AdGuardInstance `json:"origin" yaml:"origin" env:"ORIGIN"`
|
||||
Replica *AdGuardInstance `json:"replica,omitempty" yaml:"replica,omitempty" env:"REPLICA"`
|
||||
Replicas []AdGuardInstance `json:"replicas,omitempty" yaml:"replicas,omitempty"`
|
||||
Cron string `json:"cron,omitempty" yaml:"cron,omitempty" env:"CRON"`
|
||||
RunOnStart bool `json:"runOnStart,omitempty" yaml:"runOnStart,omitempty" env:"RUN_ON_START"`
|
||||
Origin AdGuardInstance `json:"origin" yaml:"origin" env:"ORIGIN"`
|
||||
Replica *AdGuardInstance `json:"replica,omitempty" yaml:"replica,omitempty" env:"REPLICA"`
|
||||
Replicas []AdGuardInstance `json:"replicas,omitempty" yaml:"replicas,omitempty" faker:"slice_len=2"`
|
||||
Cron string `json:"cron,omitempty" yaml:"cron,omitempty" env:"CRON"`
|
||||
RunOnStart bool `json:"runOnStart,omitempty" yaml:"runOnStart,omitempty" env:"RUN_ON_START"`
|
||||
PrintConfigOnly bool `json:"printConfigOnly,omitempty" yaml:"printConfigOnly,omitempty" env:"PRINT_CONFIG_ONLY"`
|
||||
ContinueOnError bool `json:"continueOnError,omitempty" yaml:"continueOnError,omitempty" env:"CONTINUE_ON_ERROR"`
|
||||
API API `json:"api,omitempty" yaml:"api,omitempty" env:"API"`
|
||||
Features Features `json:"features,omitempty" yaml:"features,omitempty" env:"FEATURES_"`
|
||||
API API `json:"api,omitempty" yaml:"api,omitempty" env:"API"`
|
||||
Features Features `json:"features,omitempty" yaml:"features,omitempty" env:"FEATURES_"`
|
||||
}
|
||||
|
||||
// API configuration
|
||||
type API struct {
|
||||
Port int `json:"port,omitempty" yaml:"port,omitempty" env:"API_PORT"`
|
||||
Port int `json:"port,omitempty" yaml:"port,omitempty" env:"API_PORT"`
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty" env:"API_USERNAME"`
|
||||
Password string `json:"password,omitempty" yaml:"password,omitempty" env:"API_PASSWORD"`
|
||||
DarkMode bool `json:"darkMode,omitempty" yaml:"darkMode,omitempty" env:"API_DARK_MODE"`
|
||||
Metrics Metrics `json:"metrics,omitempty" yaml:"metrics,omitempty" env:"API_METRICS"`
|
||||
Metrics Metrics `json:"metrics,omitempty" yaml:"metrics,omitempty" env:"API_METRICS"`
|
||||
TLS TLS `json:"tls,omitempty" yaml:"tls,omitempty" env:"API_TLS"`
|
||||
}
|
||||
|
||||
// Metrics configuration
|
||||
type Metrics struct {
|
||||
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" env:"API_METRICS_ENABLED"`
|
||||
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" env:"API_METRICS_ENABLED"`
|
||||
ScrapeInterval time.Duration `json:"scrapeInterval,omitempty" yaml:"scrapeInterval,omitempty" env:"API_METRICS_SCRAPE_INTERVAL"`
|
||||
QueryLogLimit int `json:"queryLogLimit,omitempty" yaml:"queryLogLimit,omitempty" env:"API_METRICS_QUERY_LOG_LIMIT"`
|
||||
QueryLogLimit int `json:"queryLogLimit,omitempty" yaml:"queryLogLimit,omitempty" env:"API_METRICS_QUERY_LOG_LIMIT"`
|
||||
}
|
||||
|
||||
// TLS configuration
|
||||
type TLS struct {
|
||||
CertDir string `json:"certDir,omitempty" yaml:"certDir,omitempty" env:"API_TLS_CERT_DIR"`
|
||||
CertName string `json:"certName,omitempty" yaml:"certName,omitempty" env:"API_TLS_CERT_NAME"`
|
||||
KeyName string `json:"keyName,omitempty" yaml:"keyName,omitempty" env:"API_TLS_KEY_NAME"`
|
||||
}
|
||||
|
||||
func (t TLS) Enabled() bool {
|
||||
return strings.TrimSpace(t.CertDir) != ""
|
||||
}
|
||||
|
||||
func (t TLS) Certs() (cert string, key string) {
|
||||
cert = filepath.Join(t.CertDir, defaultIfEmpty(t.CertName, "tls.crt"))
|
||||
key = filepath.Join(t.CertDir, defaultIfEmpty(t.KeyName, "tls.key"))
|
||||
return
|
||||
}
|
||||
|
||||
func defaultIfEmpty(val string, fallback string) string {
|
||||
if strings.TrimSpace(val) == "" {
|
||||
return fallback
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// Mask maks username and password
|
||||
@@ -114,15 +140,15 @@ func (cfg *Config) Init() error {
|
||||
// AdGuardInstance AdguardHome config instance
|
||||
// +k8s:deepcopy-gen=true
|
||||
type AdGuardInstance struct {
|
||||
URL string `json:"url" yaml:"url" env:"URL"`
|
||||
WebURL string `json:"webURL" yaml:"webURL" env:"WEB_URL"`
|
||||
APIPath string `json:"apiPath,omitempty" yaml:"apiPath,omitempty" env:"API_PATH"`
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty" env:"USERNAME"`
|
||||
Password string `json:"password,omitempty" yaml:"password,omitempty" env:"PASSWORD"`
|
||||
Cookie string `json:"cookie,omitempty" yaml:"cookie,omitempty" env:"COOKIE"`
|
||||
InsecureSkipVerify bool `json:"insecureSkipVerify" yaml:"insecureSkipVerify" env:"INSECURE_SKIP_VERIFY"`
|
||||
AutoSetup bool `json:"autoSetup" yaml:"autoSetup" env:"AUTO_SETUP"`
|
||||
InterfaceName string `json:"interfaceName,omitempty" yaml:"interfaceName,omitempty" env:"INTERFACE_NAME"`
|
||||
URL string `json:"url" yaml:"url" env:"URL" faker:"url"`
|
||||
WebURL string `json:"webURL" yaml:"webURL" env:"WEB_URL" faker:"url"`
|
||||
APIPath string `json:"apiPath,omitempty" yaml:"apiPath,omitempty" env:"API_PATH"`
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty" env:"USERNAME"`
|
||||
Password string `json:"password,omitempty" yaml:"password,omitempty" env:"PASSWORD"`
|
||||
Cookie string `json:"cookie,omitempty" yaml:"cookie,omitempty" env:"COOKIE"`
|
||||
InsecureSkipVerify bool `json:"insecureSkipVerify" yaml:"insecureSkipVerify" env:"INSECURE_SKIP_VERIFY"`
|
||||
AutoSetup bool `json:"autoSetup" yaml:"autoSetup" env:"AUTO_SETUP"`
|
||||
InterfaceName string `json:"interfaceName,omitempty" yaml:"interfaceName,omitempty" env:"INTERFACE_NAME"`
|
||||
DHCPServerEnabled *bool `json:"dhcpServerEnabled,omitempty" yaml:"dhcpServerEnabled,omitempty" env:"DHCP_SERVER_ENABLED"`
|
||||
|
||||
Host string `json:"-" yaml:"-"`
|
||||
@@ -161,8 +187,8 @@ func (i *AdGuardInstance) Init() error {
|
||||
}
|
||||
|
||||
func mask(s string) string {
|
||||
if s == "" {
|
||||
return "***"
|
||||
if len(s) < 3 {
|
||||
return strings.Repeat("*", len(s))
|
||||
}
|
||||
mask := strings.Repeat("*", len(s)-2)
|
||||
return fmt.Sprintf("%v%s%v", string(s[0]), mask, string(s[len(s)-1]))
|
||||
|
||||
15
pkg/types/types_fuzz_test.go
Normal file
15
pkg/types/types_fuzz_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func FuzzMask(f *testing.F) {
|
||||
testcases := []string{"", "a", "ab", "abc", "abcd"}
|
||||
for _, tc := range testcases {
|
||||
f.Add(tc)
|
||||
}
|
||||
f.Fuzz(func(t *testing.T, value string) {
|
||||
_ = mask(value)
|
||||
})
|
||||
}
|
||||
@@ -83,6 +83,15 @@ var _ = Describe("Types", func() {
|
||||
Ω(masked.API.Password).Should(Equal("p**s"))
|
||||
})
|
||||
})
|
||||
DescribeTable("mask should work correctly",
|
||||
func(value, expected string) {
|
||||
Ω(mask(value)).Should(Equal(expected))
|
||||
},
|
||||
Entry(`Empty password`, "", ""),
|
||||
Entry(`1 char password`, "a", "*"),
|
||||
Entry(`2 char password`, "ab", "**"),
|
||||
Entry(`3 char password`, "abc", "a*c"),
|
||||
)
|
||||
})
|
||||
Context("Feature", func() {
|
||||
Context("LogDisabled", func() {
|
||||
@@ -96,4 +105,35 @@ var _ = Describe("Types", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
Context("TLS", func() {
|
||||
var t TLS
|
||||
BeforeEach(func() {
|
||||
t = TLS{
|
||||
CertDir: "/path/to/certs",
|
||||
}
|
||||
})
|
||||
Context("Enabled", func() {
|
||||
It("should use enabled", func() {
|
||||
Ω(t.Enabled()).Should(BeTrue())
|
||||
})
|
||||
It("should use disabled", func() {
|
||||
t.CertDir = " "
|
||||
Ω(t.Enabled()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
Context("Certs", func() {
|
||||
It("should use default crt and key", func() {
|
||||
crt, key := t.Certs()
|
||||
Ω(crt).Should(Equal("/path/to/certs/tls.crt"))
|
||||
Ω(key).Should(Equal("/path/to/certs/tls.key"))
|
||||
})
|
||||
It("should use custom crt and key", func() {
|
||||
t.CertName = "foo.crt"
|
||||
t.KeyName = "bar.key"
|
||||
crt, key := t.Certs()
|
||||
Ω(crt).Should(Equal("/path/to/certs/foo.crt"))
|
||||
Ω(key).Should(Equal("/path/to/certs/bar.key"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,3 +12,13 @@ func PtrToString[I interface{}](i *I) string {
|
||||
}
|
||||
return fmt.Sprintf("%v", i)
|
||||
}
|
||||
|
||||
func PtrEquals[I comparable](a *I, b *I) bool {
|
||||
if a == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
if a == nil || b == nil {
|
||||
return false
|
||||
}
|
||||
return *a == *b
|
||||
}
|
||||
|
||||
28
renovate.json
Normal file
28
renovate.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"customManagers": [
|
||||
{
|
||||
"customType": "regex",
|
||||
"datasourceTemplate": "go",
|
||||
"description": "Update toolbox tools in .toolbox.mk",
|
||||
"fileMatch": [
|
||||
"^\\.toolbox\\.mk$"
|
||||
],
|
||||
"matchStrings": [
|
||||
"# renovate: packageName=(?<packageName>.+?)\\s+.+?_VERSION \\?= (?<currentValue>.+?)\\s"
|
||||
]
|
||||
},
|
||||
{
|
||||
"customType": "regex",
|
||||
"datasourceTemplate": "github-releases",
|
||||
"description": "Update github _VERSION Makefile",
|
||||
"fileMatch": [
|
||||
"^Makefile$"
|
||||
],
|
||||
"matchStrings": [
|
||||
"# renovate: packageName=(?<packageName>.+?)\\s+.+?_VERSION \\?= (?<currentValue>.+?)\\s"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencyDashboard": true
|
||||
}
|
||||
31
testdata/config/print-config_test_expected1.md
vendored
Normal file
31
testdata/config/print-config_test_expected1.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<!-- PLEASE COPY THE FOLLOWING OUTPUT AS IS INTO THE GITHUB ISSUE (Don't forget to mask your usernames, passwords, IPs and other sensitive information when using this in an issue ) -->
|
||||
|
||||
### Runtime
|
||||
|
||||
AdguardHome-Sync Version: %s
|
||||
Build: %s
|
||||
OperatingSystem: %s
|
||||
Architecture: %s
|
||||
OriginVersion: v0.0.1
|
||||
ReplicaVersions:
|
||||
- Replica 1: v0.0.2
|
||||
|
||||
### AdGuardHome sync aggregated config
|
||||
|
||||
```yaml
|
||||
origin:
|
||||
url: https://ha.xxxx.net:3000
|
||||
webURL: ""
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```ini
|
||||
BAR=bar
|
||||
FOO=foo
|
||||
```
|
||||
|
||||
<!-- END OF GITHUB ISSUE CONTENT -->
|
||||
41
testdata/config/print-config_test_expected2.md
vendored
Normal file
41
testdata/config/print-config_test_expected2.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<!-- PLEASE COPY THE FOLLOWING OUTPUT AS IS INTO THE GITHUB ISSUE (Don't forget to mask your usernames, passwords, IPs and other sensitive information when using this in an issue ) -->
|
||||
|
||||
### Runtime
|
||||
|
||||
AdguardHome-Sync Version: %s
|
||||
Build: %s
|
||||
OperatingSystem: %s
|
||||
Architecture: %s
|
||||
OriginVersion: v0.0.1
|
||||
ReplicaVersions:
|
||||
- Replica 1: v0.0.2
|
||||
|
||||
### AdGuardHome sync aggregated config
|
||||
|
||||
```yaml
|
||||
origin:
|
||||
url: https://ha.xxxx.net:3000
|
||||
webURL: ""
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
|
||||
```
|
||||
### AdGuardHome sync unmodified config file
|
||||
|
||||
Config file path: config.yaml
|
||||
|
||||
```yaml
|
||||
|
||||
origin:
|
||||
url: https://ha.xxxx.net:3000
|
||||
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```ini
|
||||
BAR=bar
|
||||
FOO=foo
|
||||
```
|
||||
|
||||
<!-- END OF GITHUB ISSUE CONTENT -->
|
||||
1
testdata/config_test_replica.yaml
vendored
1
testdata/config_test_replica.yaml
vendored
@@ -35,3 +35,4 @@ features:
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
theme: true
|
||||
|
||||
1
testdata/config_test_replicas.yaml
vendored
1
testdata/config_test_replicas.yaml
vendored
@@ -35,3 +35,4 @@ features:
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
theme: true
|
||||
|
||||
@@ -45,3 +45,4 @@ features:
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
theme: true
|
||||
|
||||
1
testdata/e2e/bin/install-chart.sh
vendored
1
testdata/e2e/bin/install-chart.sh
vendored
@@ -7,3 +7,4 @@ if [[ $(helm list --no-headers -n agh-e2e | grep agh-e2e | wc -l) == "1" ]]; the
|
||||
helm delete agh-e2e -n agh-e2e --wait
|
||||
fi
|
||||
helm install agh-e2e testdata/e2e -n agh-e2e --create-namespace --set mode=${1}
|
||||
|
||||
|
||||
2
testdata/e2e/bin/show-origin-logs.sh
vendored
2
testdata/e2e/bin/show-origin-logs.sh
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "## Pod adguardhome-origin logs" >> $GITHUB_STEP_SUMMARY
|
||||
echo "## Pod adguardhome-origin ${1} logs" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
kubectl logs adguardhome-origin >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
21
testdata/e2e/bin/show-replica-logs.sh
vendored
21
testdata/e2e/bin/show-replica-logs.sh
vendored
@@ -4,15 +4,18 @@ set -e
|
||||
for pod in $(kubectl get pods -l bakito.net/adguardhome-sync=replica -o name); do
|
||||
echo "## Pod ${pod} logs" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
LOGS=$(kubectl logs ${pod})
|
||||
K8S_LOGS=$(kubectl logs ${pod})
|
||||
# ignore certain errors
|
||||
LOGS=$(echo -e "${LOGS}" | grep -v -e "error.* deleting filter .* no such file or directory" )
|
||||
# https://github.com/AdguardTeam/AdGuardHome/issues/4944
|
||||
LOGS=$(echo -e "${LOGS}" | grep -v -e "error.* creating dhcpv4 srv")
|
||||
echo -e "${LOGS}" >> $GITHUB_STEP_SUMMARY
|
||||
ERRORS=$(echo -e "${LOGS}"} | grep '\[error\]' | wc -l)
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "Found ${ERRORS} error(s) in ${pod} log" >> $GITHUB_STEP_SUMMARY
|
||||
echo "----------------------------------------------" >> $GITHUB_STEP_SUMMARY
|
||||
LOGS=$(echo -e "${K8S_LOGS}" |
|
||||
grep -v -e "error.* deleting filter .* no such file or directory" |
|
||||
grep -v -e '\[error\] storage: recovered from panic: runtime' # https://github.com/AdguardTeam/AdGuardHome/issues/7315
|
||||
)
|
||||
|
||||
echo -e "${K8S_LOGS}" >> $GITHUB_STEP_SUMMARY
|
||||
ERRORS=$(echo -e "${LOGS}"} | grep '\[error\]' | wc -l)
|
||||
TOTAL_ERRORS=$(echo -e "${K8S_LOGS}"} | grep '\[error\]' | wc -l)
|
||||
IGNORED_ERRORS=$(echo "${TOTAL_ERRORS} - ${ERRORS}" | bc)
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "Found ${ERRORS} error(s) (${IGNORED_ERRORS} ignored) in ${pod} log" >> $GITHUB_STEP_SUMMARY
|
||||
echo "----------------------------------------------" >> $GITHUB_STEP_SUMMARY
|
||||
done
|
||||
|
||||
2
testdata/e2e/bin/show-sync-metrics.sh
vendored
2
testdata/e2e/bin/show-sync-metrics.sh
vendored
@@ -7,5 +7,5 @@ sleep 30
|
||||
|
||||
echo "## Pod adguardhome-sync metrics" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
curl http://localhost:9090/metrics -s >> $GITHUB_STEP_SUMMARY
|
||||
curl ${1}://localhost:9090/metrics -s -k >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
3
testdata/e2e/bin/wait-for-start.sh
vendored
Executable file
3
testdata/e2e/bin/wait-for-start.sh
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/adguardhome-sync --timeout=1m
|
||||
4
testdata/e2e/bin/wait-for-sync.sh
vendored
4
testdata/e2e/bin/wait-for-sync.sh
vendored
@@ -1,12 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/adguardhome-sync --timeout=1m
|
||||
|
||||
kubectl port-forward pod/adguardhome-sync 9090:9090 &
|
||||
|
||||
for i in {1..6}; do
|
||||
sleep 10
|
||||
RUNNING=$(curl http://localhost:9090/api/v1/status -s | jq -r .syncRunning)
|
||||
RUNNING=$(curl ${1}://localhost:9090/api/v1/status -s -k | jq -r .syncRunning)
|
||||
echo "SyncRunning = ${RUNNING}"
|
||||
if [[ "${RUNNING}" == "false" ]]; then
|
||||
exit 0
|
||||
|
||||
44
testdata/e2e/resources/AdGuardHome.yaml
vendored
44
testdata/e2e/resources/AdGuardHome.yaml
vendored
@@ -18,19 +18,18 @@ dns:
|
||||
port: 53
|
||||
anonymize_client_ip: false
|
||||
ratelimit: 20
|
||||
ratelimit_whitelist: [ ]
|
||||
ratelimit_whitelist: []
|
||||
refuse_any: true
|
||||
upstream_dns:
|
||||
- https://dns10.quad9.net/dns-query
|
||||
- 8.8.8.8
|
||||
upstream_dns_file: ""
|
||||
bootstrap_dns:
|
||||
- 1.1.1.1:53
|
||||
fallback_dns: [ ]
|
||||
all_servers: false
|
||||
fastest_addr: false
|
||||
fallback_dns: []
|
||||
upstream_mode: load_balance
|
||||
fastest_timeout: 1s
|
||||
allowed_clients: [ ]
|
||||
disallowed_clients: [ ]
|
||||
allowed_clients: []
|
||||
disallowed_clients: []
|
||||
blocked_hosts:
|
||||
- version.bind
|
||||
- id.server
|
||||
@@ -42,7 +41,7 @@ dns:
|
||||
cache_ttl_min: 0
|
||||
cache_ttl_max: 0
|
||||
cache_optimistic: true
|
||||
bogus_nxdomain: [ ]
|
||||
bogus_nxdomain: []
|
||||
aaaa_disabled: false
|
||||
enable_dnssec: false
|
||||
edns_client_subnet:
|
||||
@@ -51,17 +50,19 @@ dns:
|
||||
use_custom: false
|
||||
max_goroutines: 300
|
||||
handle_ddr: true
|
||||
ipset: [ ]
|
||||
ipset: []
|
||||
ipset_file: ""
|
||||
bootstrap_prefer_ipv6: false
|
||||
upstream_timeout: 10s
|
||||
private_networks: [ ]
|
||||
private_networks: []
|
||||
use_private_ptr_resolvers: true
|
||||
local_ptr_upstreams: [ ]
|
||||
local_ptr_upstreams: []
|
||||
use_dns64: false
|
||||
dns64_prefixes: [ ]
|
||||
dns64_prefixes: []
|
||||
serve_http3: false
|
||||
use_http3_upstreams: false
|
||||
serve_plain_dns: true
|
||||
hostsfile_enabled: true
|
||||
tls:
|
||||
enabled: false
|
||||
server_name: ""
|
||||
@@ -78,13 +79,15 @@ tls:
|
||||
private_key_path: ""
|
||||
strict_sni_check: false
|
||||
querylog:
|
||||
ignored: [ ]
|
||||
dir_path: ""
|
||||
ignored: []
|
||||
interval: 6h
|
||||
size_memory: 1000
|
||||
enabled: true
|
||||
file_enabled: true
|
||||
statistics:
|
||||
ignored: [ ]
|
||||
dir_path: ""
|
||||
ignored: []
|
||||
interval: 24h
|
||||
enabled: true
|
||||
filters:
|
||||
@@ -96,7 +99,7 @@ filters:
|
||||
url: https://adaway.org/hosts.txt
|
||||
name: AdAway Default Blocklist
|
||||
id: 2
|
||||
whitelist_filters: [ ]
|
||||
whitelist_filters: []
|
||||
user_rules:
|
||||
- '||metrics2.data.hicloud.com^$important'
|
||||
- '||www.curiouscorrespondence.com^$important'
|
||||
@@ -113,7 +116,7 @@ dhcp:
|
||||
range_end: 1.2.3.56
|
||||
lease_duration: 86400
|
||||
icmp_timeout_msec: 1000
|
||||
options: [ ]
|
||||
options: []
|
||||
dhcpv6:
|
||||
range_start: ""
|
||||
lease_duration: 86400
|
||||
@@ -150,7 +153,7 @@ filtering:
|
||||
blocking_mode: default
|
||||
parental_block_host: family-block.dns.adguard.com
|
||||
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||
rewrites: [ ]
|
||||
rewrites: []
|
||||
safebrowsing_cache_size: 1048576
|
||||
safesearch_cache_size: 1048576
|
||||
parental_cache_size: 1048576
|
||||
@@ -170,8 +173,6 @@ clients:
|
||||
hosts: true
|
||||
persistent:
|
||||
- name: Device 1
|
||||
tags:
|
||||
- device_1
|
||||
ids:
|
||||
- 2.2.2.2
|
||||
blocked_services:
|
||||
@@ -183,7 +184,7 @@ clients:
|
||||
- qq
|
||||
- vk
|
||||
- ok
|
||||
upstreams: [ ]
|
||||
upstreams: []
|
||||
use_global_settings: true
|
||||
filtering_enabled: false
|
||||
parental_enabled: false
|
||||
@@ -192,6 +193,7 @@ clients:
|
||||
ignore_querylog: false
|
||||
ignore_statistics: false
|
||||
log:
|
||||
enabled: true
|
||||
file: ""
|
||||
max_backups: 0
|
||||
max_size: 100
|
||||
@@ -203,4 +205,4 @@ os:
|
||||
group: ""
|
||||
user: ""
|
||||
rlimit_nofile: 0
|
||||
schema_version: 27
|
||||
schema_version: 28
|
||||
|
||||
93
testdata/e2e/templates/configmap-certs.yaml
vendored
Normal file
93
testdata/e2e/templates/configmap-certs.yaml
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
{{- if eq .Values.mode "env" }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: certs
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
my.crt: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE7zCCAtcCFFthw5GxzLaZC/pTTlbwju6vYr9pMA0GCSqGSIb3DQEBCwUAMDMx
|
||||
CzAJBgNVBAYTAkNIMRMwEQYDVQQIDApTb21lLVN0YXRlMQ8wDQYDVQQKDAZiYWtp
|
||||
dG8wIBcNMjQwNDA0MDUxOTMyWhgPMjEyNDAzMTEwNTE5MzJaMDMxCzAJBgNVBAYT
|
||||
AkNIMRMwEQYDVQQIDApTb21lLVN0YXRlMQ8wDQYDVQQKDAZiYWtpdG8wggIiMA0G
|
||||
CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCenHJ0SunHqdtBdG8d5Uy8y5KESOPE
|
||||
GCpcjNetSR53binlV3QjVckrA+6tHQBR3yXpSgHWU424fR3eTdHsbS9/8/pAnV0V
|
||||
CAaUntbCr5CJ8ww2zRlGSz6IlxkwJkqx4crmYUcTm6XNcEm5kSoBmFR1s8TiQAQ8
|
||||
CnJyt4m3S5jSKnexAMi2l2LP4F5P5MwLHdpl2sfRYydWOoJty9nSYuRxarv7G7e3
|
||||
N102voL3W2F9Dk8QbKF1Kzxcfmh+4twNz/YfUxxB3tggrCGHfMu4EcvMrFCkKhNv
|
||||
sFcG9aZ0gNj4x54vCOMK+LuVd8JZQMcGBdcxZUq+q4nyj4dxFDKSUjZ+nVjdbuab
|
||||
dk72dVbv/r2j6aGFuZDwPeYrKOyGCUlzyPvtX3qDjrebvalkrua0ApJLTiUntQK4
|
||||
E+8P658GUzwqhKi6COEmgJgZO1+xIhO68OzPS6qj8OvgOw97VJqWsnTkDeu5Xd3E
|
||||
qW37lk62EQ75FCLaWAmyBcxTDlIWNfwvSlI57Iyw0ec9ziN4JP+6pX3QTcj69Kvc
|
||||
ERExUNGWcyQVYiCFigBqL/UtGO73PA4kb8P6Zef0oTx7siw4ysImvQ/RHvbArXPE
|
||||
iqxg/afjJz/w7fTTwk9DRW12hiWj7+ojZMcoYCj1PcOlmZvchwZRdN8Lp37wm11I
|
||||
EYxdoBQVRWk0vwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQB6H+z2IEtiBTOIFnYJ
|
||||
++CvZWw0CLPSpuFTwpDRIVUbrfhpFoXMwb6ungaqrGNXv3H4HQXl2EwXwZomsy2K
|
||||
/pjk/0rHFdleEtJ4beSv44ToGCL+RqeU38sGuxCDQBCxIqGcbkErkqEYJqaSEV9I
|
||||
elKjBA5PEy+WO/P+J5UYU6aY+59C+ZHrZ8HzoPUGrZ6ESu9Wm/9iOpUn4DWFzOOu
|
||||
E/14QQqpHzHRvpbfOb/dsnEYv7JoiOaXhOedKmx5k+bLhNCXOJiqyqphNp0Io3Fr
|
||||
8i6IxfvOo/6nw9sQ02E6PjNyC5bRq7TUrqffTcCRq7EYhJoK43V7nzLpUBItBF7K
|
||||
FszFnvBxvgPtUdbhs6O8U8pqoPw1vCnoJLnerGfN1fEclV7Sbf3d1hCYXtHzmpZM
|
||||
qflEkJIPSgkr8dyi2JjSQR5AJUtB5/VAZwBATNKNYINfnEVzyle+64iVaKteRt9e
|
||||
yeLoy/ktTZSlQbb7/qg4NtQx9SA5PlYVMLj20S5HwStGQhLIb5lrwzkHNUZmkDWr
|
||||
LUX1ufOfhNpCH2Egn078pyEn88B5iRTga2auCk3siOs9H3wmbT2r57E7ddX3l9Sf
|
||||
MzO/8HyfNoa2RUTnJHdyduAT7VytyJSSRmfeapw9ITngZHGmpPhisKhxb6IoZm0J
|
||||
j10kyQuFfNcZKlNa3D7XFvqzWQ==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
my.key: |
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCenHJ0SunHqdtB
|
||||
dG8d5Uy8y5KESOPEGCpcjNetSR53binlV3QjVckrA+6tHQBR3yXpSgHWU424fR3e
|
||||
TdHsbS9/8/pAnV0VCAaUntbCr5CJ8ww2zRlGSz6IlxkwJkqx4crmYUcTm6XNcEm5
|
||||
kSoBmFR1s8TiQAQ8CnJyt4m3S5jSKnexAMi2l2LP4F5P5MwLHdpl2sfRYydWOoJt
|
||||
y9nSYuRxarv7G7e3N102voL3W2F9Dk8QbKF1Kzxcfmh+4twNz/YfUxxB3tggrCGH
|
||||
fMu4EcvMrFCkKhNvsFcG9aZ0gNj4x54vCOMK+LuVd8JZQMcGBdcxZUq+q4nyj4dx
|
||||
FDKSUjZ+nVjdbuabdk72dVbv/r2j6aGFuZDwPeYrKOyGCUlzyPvtX3qDjrebvalk
|
||||
rua0ApJLTiUntQK4E+8P658GUzwqhKi6COEmgJgZO1+xIhO68OzPS6qj8OvgOw97
|
||||
VJqWsnTkDeu5Xd3EqW37lk62EQ75FCLaWAmyBcxTDlIWNfwvSlI57Iyw0ec9ziN4
|
||||
JP+6pX3QTcj69KvcERExUNGWcyQVYiCFigBqL/UtGO73PA4kb8P6Zef0oTx7siw4
|
||||
ysImvQ/RHvbArXPEiqxg/afjJz/w7fTTwk9DRW12hiWj7+ojZMcoYCj1PcOlmZvc
|
||||
hwZRdN8Lp37wm11IEYxdoBQVRWk0vwIDAQABAoICAEx3eTh2m1F+oq1iQGXF0+Kb
|
||||
NEZhS6mQyu92mU46F52Vd05RhLS6WXNLAIjmF+7gqYrYep1FB+ifLUSs+N1GYGWM
|
||||
DqSTGTqX9XA2SaxvbrwK+GL9K0e34+x/CA4uD8nFZQf/cwBRhDRQg8KaaQl+0o0y
|
||||
P2OiYEg/8yA6OwMqx4DfJ3gmvB1HS8STU3SqBfMAD/gV60qXxnGsYJAlfJyQv7is
|
||||
L/dmTAJhByfq3gH5xLzBJr3w2UA/OWkQKjmuDk/8aBh+/XsGP+U0hy+mKyLRNZM1
|
||||
qeUTQe6RMcuxp2+4ZKI/vpPHcYorE2iCZaiY8bqGG1J9lnTpB2bw6mfKSH1BdHKB
|
||||
BCpnvMebe56hfNzQgbE5N4XZUHE4fdFRSDe0cLyagN+5BAekaA10E5cW5/7bfs4P
|
||||
VFtJgcj3wSRsnYQ4UZoA/9LE6IeQXuHauUFf9lGvy26oW8FkuTysZk6w5uxyJOew
|
||||
qM0/r7DaGZ6umAsINgLMV/2+ksVDGdOpcHmd7S6Gi26vFKIPdIXWO6BtVej6Mkb9
|
||||
vUKEEnJbx+gdiehAO63WAg9KR77bHwTXFPYGvza3mB1SXrZCGjjfBnI5yQP6VDwG
|
||||
uRa0fY/thbsS8QdHc6lmMJNKJnCyes3sG99qcpOX0HBWRpGt9YzjHMK16uQbMPn1
|
||||
0ApKa/1j/izsQtMkai81AoIBAQDLi/WbQY5jrKesRjSN7AOGND0Ge/NHF7hPIKW6
|
||||
Ql+BKiu3AiADemiXfnpeBS8OtkqxFWNFT6Ob2uv5pF2aRzP1un8mTaSipQu5iEOz
|
||||
tejyiWGMCzKaGPksB/d2spDxaDTs1KIyM+YVP2ynx8IGwet2mRcWZ4ixyQxgaj2o
|
||||
vZeCesxJZSPlt+D0NoPlthwDx4B7D49tU288WEvhPspcAjW3udE4WV4dnmFTZFtD
|
||||
ZmJ9GrW4rQsti6D2f+hnkWi17F+qGR0B7B4yyE66W8y3wzMfq0/tZzBpAH+azwjk
|
||||
qkHIbePrWTpwLwbAK4L4cKENs+yivAldfUj4kgVUhVLCscCrAoIBAQDHfBKKF/DK
|
||||
BsGvWSxo5QahJza2px1walQeE0AifkDYkLI+fyYnArOTUKKAC1/SxI21PWlPPJHz
|
||||
bt2lhF+I3+DFJTDLsUrBUN923rTpt1WpQVvBNzUFVz6JDlYr6VUOVOX0KY+LVE20
|
||||
iPmZLrutgO3JRMMFWOaT0ptV1dVx/Eyd4BiT+NfK06D4ZSHGZ6QAsuUmjc+M5VfM
|
||||
nRbuDlpMgOcBQYQSAfrA+LT6jZorv0mOO6rigNWzIP8FlsJxf1A5o5zL9CYAOOk/
|
||||
lRWI7K4LSP4TTcTW8DnXqVH7q569d2QA/RS2B1EUEdpNuT2aKIAsNNrhA3JCX6S9
|
||||
UZm9KOBwYuQ9AoIBAQCbD8ZNPkXA/RjHDryemXud01HiDK8qK5HHBfH60PF8rqma
|
||||
w02sGKZxMnL6CSzuIkUIXmi/tonHA6HdDjAYhcG5oxeWEHQpS16BOqOI1j3d9naP
|
||||
f0BPUFMSDgehLytoHKClAt+FKzBOY4Dc2Dqhdz1vnfSOptTly2lYUdcjIzu2tOHH
|
||||
z/rm14vRv23/oxn4bxUbqqDzAiqtZ/52W6VBLpXJnw8ZxEsEeVFffAZidC73a0+g
|
||||
noLzcXlwD8T2kTmZzbabGIKWok/nE92V7rUoENZze8hp7MBeXXjYcHwv5twyWjTV
|
||||
Z6YzLEASSZN+vB6VF8pftqvTwsvCQUs6Nk7z7wH9AoIBAA6EH9E+tr3syfFZmtqz
|
||||
N81ITjnyZTkF88MQgY1BBLT9qorTs9II50pkBr8slLeAqBM1OdGTRceiHKzrugv6
|
||||
xp9x+mAIMblpiilbQWz0c15SrDueKdSOqbVNfsXJP/BAC0++KnzoEJN/mDImbW/N
|
||||
vv/zagGcm4LMQ5N2cQbPZj/iy8cQx5sx1TfeHBwU9KE8Y2Jv1VeaZM417DI8hyOk
|
||||
CatUuiiZTkb2kizdWwet7stT2jaLS4Gyd/xPIS0jJ5JaLpHE3XMMsSR4U83X8z5M
|
||||
/HgpI5bEemEQKDAZJ/7/jh5oTDaGx8afGfSn8yyhn9oXqonPN2RPE2zXYEmcjOCA
|
||||
wb0CggEBAI9ztuEtsucOVKa52Itzvk8sZn2MF1kpUPHGF6/VW6a/s45wvvFFW3PE
|
||||
BjqmgJX8s2ZLgOgWE/wEmEpHX+lxmebYJ3bmOsx5eGfA1eZBypWCBYBSfezf/1zD
|
||||
3AD65+gwO4GhnSN4zsrlyVC6SsWEaeu+sxexHt15YJI9SkwCkvZTYoLqe9nMcAjY
|
||||
h41p/i6bhl9ODZPd1+hL631EFWguyMVSVTDgIG141OIYKz5hVQZ08ddrwHB2gPf6
|
||||
JSdU2DFOD6tNCfvTYAMvUfkoIt3g9RDJ5dTdR9J/3efm0ZIutcYcHiASIcubPU9x
|
||||
r8Ww1tZIoBx/s50i7X1JFyuXp0TWQsI=
|
||||
-----END PRIVATE KEY-----
|
||||
|
||||
{{- end }}
|
||||
@@ -8,6 +8,9 @@ data:
|
||||
API_PORT: '9090'
|
||||
API_METRICS_ENABLED: 'true'
|
||||
API_METRICS_SCRAPE_INTERVAL: '30s'
|
||||
API_TLS_CERT_DIR: '/certs'
|
||||
API_TLS_CERT_NAME: 'my.crt'
|
||||
API_TLS_KEY_NAME: 'my.key'
|
||||
LOG_FORMAT: 'json'
|
||||
ORIGIN_URL: 'http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
ORIGIN_PASSWORD: 'password'
|
||||
|
||||
@@ -26,5 +26,12 @@ spec:
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: sync-conf
|
||||
volumeMounts:
|
||||
- name: certs
|
||||
mountPath: /certs
|
||||
restartPolicy: Never
|
||||
volumes:
|
||||
- name: certs
|
||||
configMap:
|
||||
name: certs
|
||||
{{- end }}
|
||||
|
||||
2
testdata/e2e/values.yaml
vendored
2
testdata/e2e/values.yaml
vendored
@@ -8,4 +8,4 @@ mode: env
|
||||
|
||||
kubectl:
|
||||
repository: bitnami/kubectl
|
||||
tag: 1.27
|
||||
tag: "1.30"
|
||||
|
||||
6
tools.go
6
tools.go
@@ -4,11 +4,5 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
_ "github.com/bakito/semver"
|
||||
_ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen"
|
||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
_ "github.com/goreleaser/goreleaser"
|
||||
_ "github.com/onsi/ginkgo/v2/ginkgo"
|
||||
_ "go.uber.org/mock/mockgen"
|
||||
_ "k8s.io/code-generator/cmd/deepcopy-gen"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user