2021-04-07 03:27:33 +08:00
|
|
|
[![Go](https://github.com/bakito/adguardhome-sync/actions/workflows/go.yml/badge.svg)](https://github.com/bakito/adguardhome-sync/actions/workflows/go.yml)
|
2024-01-15 03:50:29 +08:00
|
|
|
[![e2e tests](https://github.com/bakito/adguardhome-sync/actions/workflows/e2e.yaml/badge.svg)](https://github.com/bakito/adguardhome-sync/actions/workflows/e2e.yaml)
|
2021-04-07 03:27:33 +08:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/bakito/adguardhome-sync)](https://goreportcard.com/report/github.com/bakito/adguardhome-sync)
|
2022-11-21 01:49:36 +08:00
|
|
|
[![Coverage Status](https://coveralls.io/repos/github/bakito/adguardhome-sync/badge.svg?branch=main&service=github)](https://coveralls.io/github/bakito/adguardhome-sync?branch=main)
|
2021-04-19 00:28:35 +08:00
|
|
|
|
2021-03-28 06:44:48 +08:00
|
|
|
# AdGuardHome sync
|
|
|
|
|
2022-08-10 03:23:40 +08:00
|
|
|
Synchronize [AdGuardHome](https://github.com/AdguardTeam/AdGuardHome) config to replica instances.
|
2021-03-28 16:30:00 +08:00
|
|
|
|
2024-01-07 10:05:44 +08:00
|
|
|
## FAQ
|
|
|
|
|
|
|
|
Please check the wiki for [FAQ](https://github.com/bakito/adguardhome-sync/wiki/FAQ).
|
|
|
|
|
2024-01-11 03:12:08 +08:00
|
|
|
## Deprecation of Environment Variables as of v0.6.0
|
|
|
|
|
|
|
|
The following environment variables have been deprecated and replaced with better readable ones:
|
|
|
|
Deprecated variables are still supported but will be logged as warning.
|
|
|
|
| Deprecated | Replacement |
|
|
|
|
| :----------- |:----------- |
|
|
|
|
| RUNONSTART | RUN_ON_START |
|
|
|
|
| PRINTCONFIGONLY | PRINT_CONFIG_ONLY |
|
|
|
|
| CONTINUE_ON_ERROR | CONTINUE_ON_ERROR |
|
|
|
|
| API_DARKMODE | API_DARK_MODE |
|
|
|
|
| FEATURES_DHCP_SERVERCONFIG | FEATURES_DHCP_SERVER_CONFIG |
|
|
|
|
| FEATURES_DHCP_STATICLEASES | FEATURES_DHCP_STATIC_LEASES |
|
|
|
|
| FEATURES_DNS_ACCESSLISTS | FEATURES_DNS_ACCESS_LISTS |
|
|
|
|
| FEATURES_DNS_SERVERCONFIG | FEATURES_DNS_SERVER_CONFIG |
|
|
|
|
| FEATURES_GENERALSETTINGS | FEATURES_GENERAL_SETTINGS |
|
|
|
|
| FEATURES_QUERYLOGCONFIG | FEATURES_QUERY_LOG_CONFIG |
|
|
|
|
| FEATURES_STATSCONFIG | FEATURES_STATS_CONFIG |
|
|
|
|
| FEATURES_CLIENTSETTINGS | FEATURES_CLIENT_SETTINGS |
|
|
|
|
| ORIGIN_WEBURL | ORIGIN_WEB_URL |
|
|
|
|
| ORIGIN_APIPATH | ORIGIN_API_PATH |
|
|
|
|
| ORIGIN_INSECURE_SKIP_VERIFY | ORIGIN_INSECURE_SKIP_VERIFY |
|
|
|
|
| *REPLICA_WEBURL | REPLICA_WEB_URL |
|
|
|
|
| *REPLICA_APIPATH | REPLICA_API_PATH |
|
|
|
|
| *REPLICA_INSECURE_SKIP_VERIFY | REPLICA_INSECURE_SKIP_VERIFY |
|
|
|
|
| *REPLICA_AUTOSETUP | REPLICA_AUTO_SETUP |
|
|
|
|
| *REPLICA_INTERFACENAME | REPLICA_INTERFACE_NAME |
|
|
|
|
|
|
|
|
\* is also valid for numbered `REPLICA#_` variables
|
|
|
|
|
2021-03-28 16:30:00 +08:00
|
|
|
## Current sync features
|
|
|
|
|
2021-03-31 08:28:18 +08:00
|
|
|
- General Settings
|
2021-03-28 16:30:00 +08:00
|
|
|
- Filters
|
|
|
|
- Rewrites
|
|
|
|
- Services
|
|
|
|
- Clients
|
2021-08-08 16:15:29 +08:00
|
|
|
- DNS Config
|
|
|
|
- DHCP Config
|
2021-03-28 16:30:00 +08:00
|
|
|
|
2021-11-01 15:56:12 +08:00
|
|
|
By default, all features are enabled. Single features can be disabled in the config.
|
|
|
|
|
2021-04-19 04:03:57 +08:00
|
|
|
### Setup of initial instances
|
|
|
|
|
2021-08-08 16:15:29 +08:00
|
|
|
New AdGuardHome replica instances can be automatically installed if enabled via the config autoSetup. During automatic
|
|
|
|
installation, the admin interface will be listening on port 3000 in runtime.
|
2021-04-19 04:03:57 +08:00
|
|
|
|
|
|
|
To skip automatic setup
|
|
|
|
|
2021-03-28 16:30:00 +08:00
|
|
|
## Install
|
|
|
|
|
2022-01-24 14:54:30 +08:00
|
|
|
Get from [releases](https://github.com/bakito/adguardhome-sync/releases) or install from source
|
|
|
|
|
2021-03-28 16:30:00 +08:00
|
|
|
```bash
|
2022-01-24 14:54:30 +08:00
|
|
|
go install github.com/bakito/adguardhome-sync@latest
|
2021-03-28 16:30:00 +08:00
|
|
|
```
|
|
|
|
|
2021-04-05 19:33:21 +08:00
|
|
|
## Prerequisites
|
|
|
|
|
2021-04-19 04:03:57 +08:00
|
|
|
Both the origin instance must be initially setup via the AdguardHome installation wizard.
|
2021-04-05 19:33:21 +08:00
|
|
|
|
2023-08-05 13:38:21 +08:00
|
|
|
## Username / Password vs. Cookie
|
|
|
|
|
2024-01-07 10:05:44 +08:00
|
|
|
Some instances of AdGuard Home do not support basic authentication. For instance, many routers with built-in Adguard
|
|
|
|
Home support do not. If this is the case, a valid cookie may be provided instead. If the router protects the AdGuard
|
|
|
|
instance behind its own authentication, the cookie from an authenticated request may allow the sync to succeed.
|
2023-08-05 13:38:21 +08:00
|
|
|
|
|
|
|
- This has been tested successfully against GL.Inet routers with AdGuard Home.
|
|
|
|
- Note: due to the short validity of cookies, this approach is likely only suitable for one-time syncs
|
|
|
|
|
2022-10-17 04:03:02 +08:00
|
|
|
## Run Linux/Mac
|
2021-03-28 16:30:00 +08:00
|
|
|
|
|
|
|
```bash
|
2021-03-28 22:29:18 +08:00
|
|
|
|
2023-03-21 18:14:44 +08:00
|
|
|
export LOG_LEVEL=info
|
2021-03-28 20:09:31 +08:00
|
|
|
export ORIGIN_URL=https://192.168.1.2:3000
|
2021-03-28 16:30:00 +08:00
|
|
|
export ORIGIN_USERNAME=username
|
|
|
|
export ORIGIN_PASSWORD=password
|
2023-08-05 13:38:21 +08:00
|
|
|
# export ORIGIN_COOKIE=Origin-Cookie-Name=CCCOOOKKKIIIEEE
|
2021-03-28 20:09:31 +08:00
|
|
|
export REPLICA_URL=http://192.168.1.3
|
2021-03-28 16:30:00 +08:00
|
|
|
export REPLICA_USERNAME=username
|
|
|
|
export REPLICA_PASSWORD=password
|
2023-08-05 13:38:21 +08:00
|
|
|
# export REPLICA_COOKIE=Replica-Cookie-Name=CCCOOOKKKIIIEEE
|
2021-03-28 16:30:00 +08:00
|
|
|
|
2021-03-28 22:29:18 +08:00
|
|
|
# run once
|
2021-03-28 20:09:31 +08:00
|
|
|
adguardhome-sync run
|
2021-03-28 22:29:18 +08:00
|
|
|
|
|
|
|
# run as daemon
|
|
|
|
adguardhome-sync run --cron "*/10 * * * *"
|
2021-03-28 23:04:41 +08:00
|
|
|
```
|
|
|
|
|
2022-10-17 04:03:02 +08:00
|
|
|
## Run Windows
|
|
|
|
|
|
|
|
```bash
|
|
|
|
@ECHO OFF
|
|
|
|
@TITLE AdGuardHome-Sync
|
|
|
|
|
|
|
|
REM set LOG_LEVEL=debug
|
|
|
|
set LOG_LEVEL=info
|
|
|
|
REM set LOG_LEVEL=warn
|
|
|
|
REM set LOG_LEVEL=error
|
|
|
|
|
2022-10-18 06:33:51 +08:00
|
|
|
set ORIGIN_URL=http://192.168.1.2:3000
|
|
|
|
set ORIGIN_USERNAME=username
|
|
|
|
set ORIGIN_PASSWORD=password
|
2023-08-05 13:38:21 +08:00
|
|
|
# set ORIGIN_COOKIE=Origin-Cookie-Name=CCCOOOKKKIIIEEE
|
2022-10-17 04:03:02 +08:00
|
|
|
|
2022-10-18 06:33:51 +08:00
|
|
|
set REPLICA_URL=http://192.168.2.2:3000
|
|
|
|
set REPLICA_USERNAME=username
|
|
|
|
set REPLICA_PASSWORD=password
|
2023-08-05 13:38:21 +08:00
|
|
|
# set REPLICA_COOKIE=Replica-Cookie-Name=CCCOOOKKKIIIEEE
|
2022-10-17 04:03:02 +08:00
|
|
|
|
|
|
|
set FEATURES_DHCP=false
|
|
|
|
set FEATURES_DHCP_SERVERCONFIG=false
|
|
|
|
set FEATURES_DHCP_STATICLEASES=false
|
|
|
|
|
|
|
|
# run once
|
|
|
|
adguardhome-sync run
|
|
|
|
|
|
|
|
# run as daemon
|
|
|
|
adguardhome-sync run --cron "*/10 * * * *"
|
|
|
|
```
|
|
|
|
|
2021-04-06 01:26:35 +08:00
|
|
|
## docker cli
|
|
|
|
|
|
|
|
```bash
|
|
|
|
docker run -d \
|
|
|
|
--name=adguardhome-sync \
|
|
|
|
-p 8080:8080 \
|
|
|
|
-v /path/to/appdata/config/adguardhome-sync.yaml:/config/adguardhome-sync.yaml \
|
|
|
|
--restart unless-stopped \
|
2022-01-25 03:23:04 +08:00
|
|
|
ghcr.io/bakito/adguardhome-sync:latest
|
2021-04-06 01:26:35 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## docker compose
|
2021-04-06 03:04:01 +08:00
|
|
|
|
|
|
|
### config file
|
2021-04-19 00:28:35 +08:00
|
|
|
|
2021-04-06 01:26:35 +08:00
|
|
|
```yaml
|
|
|
|
---
|
|
|
|
version: "2.1"
|
|
|
|
services:
|
|
|
|
adguardhome-sync:
|
2022-01-25 03:23:04 +08:00
|
|
|
image: ghcr.io/bakito/adguardhome-sync
|
2021-04-06 01:26:35 +08:00
|
|
|
container_name: adguardhome-sync
|
2022-05-06 02:25:20 +08:00
|
|
|
command: run --config /config/adguardhome-sync.yaml
|
2021-04-06 01:26:35 +08:00
|
|
|
volumes:
|
|
|
|
- /path/to/appdata/config/adguardhome-sync.yaml:/config/adguardhome-sync.yaml
|
|
|
|
ports:
|
|
|
|
- 8080:8080
|
|
|
|
restart: unless-stopped
|
2021-04-06 03:04:01 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### env
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
---
|
|
|
|
version: "2.1"
|
|
|
|
services:
|
|
|
|
adguardhome-sync:
|
2022-01-25 03:23:04 +08:00
|
|
|
image: ghcr.io/bakito/adguardhome-sync
|
2021-04-06 03:04:01 +08:00
|
|
|
container_name: adguardhome-sync
|
2021-04-06 03:23:15 +08:00
|
|
|
command: run
|
2021-04-06 03:04:01 +08:00
|
|
|
environment:
|
2023-08-05 13:38:21 +08:00
|
|
|
LOG_LEVEL: "info"
|
|
|
|
ORIGIN_URL: "https://192.168.1.2:3000"
|
2024-01-09 02:39:47 +08:00
|
|
|
# ORIGIN_WEB_URL: "https://some-other.url" # used in the web interface (default: <origin-url>
|
2024-01-07 16:55:21 +08:00
|
|
|
|
2023-08-05 13:38:21 +08:00
|
|
|
ORIGIN_USERNAME: "username"
|
|
|
|
ORIGIN_PASSWORD: "password"
|
|
|
|
REPLICA_URL: "http://192.168.1.3"
|
|
|
|
REPLICA_USERNAME: "username"
|
|
|
|
REPLICA_PASSWORD: "password"
|
|
|
|
REPLICA1_URL: "http://192.168.1.4"
|
|
|
|
REPLICA1_USERNAME: "username"
|
|
|
|
REPLICA1_PASSWORD: "password"
|
2024-01-09 02:39:47 +08:00
|
|
|
REPLICA1_API_PATH: "/some/path/control"
|
|
|
|
# REPLICA1_WEB_URL: "https://some-other.url" # used in the web interface (default: <replica-url>
|
|
|
|
# REPLICA1_AUTO_SETUP: true # if true, AdGuardHome is automatically initialized.
|
|
|
|
# REPLICA1_INTERFACE_NAME: 'ens18' # use custom dhcp interface name
|
|
|
|
# REPLICA1_DHCP_SERVER_ENABLED: true/false (optional) enables/disables the dhcp server on the replica
|
2023-08-05 13:38:21 +08:00
|
|
|
CRON: "*/10 * * * *" # run every 10 minutes
|
2022-07-08 04:20:19 +08:00
|
|
|
RUNONSTART: true
|
2024-01-08 05:44:32 +08:00
|
|
|
# CONTINUE_ON_ERROR: false # If enabled, the synchronisation task will not fail on single errors, but will log the errors and continue
|
2023-03-16 00:04:53 +08:00
|
|
|
|
|
|
|
# Configure the sync API server, disabled if api port is 0
|
|
|
|
API_PORT: 8080
|
|
|
|
|
2021-11-01 15:56:12 +08:00
|
|
|
# Configure sync features; by default all features are enabled.
|
2024-01-09 02:39:47 +08:00
|
|
|
# FEATURES_GENERAL_SETTINGS: true
|
|
|
|
# FEATURES_QUERY_LOG_CONFIG: true
|
|
|
|
# FEATURES_STATS_CONFIG: true
|
|
|
|
# FEATURES_CLIENT_SETTINGS: true
|
2022-07-08 04:20:19 +08:00
|
|
|
# FEATURES_SERVICES: true
|
|
|
|
# FEATURES_FILTERS: true
|
2024-01-09 02:39:47 +08:00
|
|
|
# FEATURES_DHCP_SERVER_CONFIG: true
|
|
|
|
# FEATURES_DHCP_STATIC_LEASES: true
|
|
|
|
# FEATURES_DNS_SERVER_CONFIG: true
|
|
|
|
# FEATURES_DNS_ACCESS_LISTS: true
|
2022-07-08 04:20:19 +08:00
|
|
|
# FEATURES_DNS_REWRITES: true
|
2021-04-06 03:04:01 +08:00
|
|
|
ports:
|
|
|
|
- 8080:8080
|
|
|
|
restart: unless-stopped
|
2021-04-06 01:26:35 +08:00
|
|
|
```
|
|
|
|
|
2021-03-28 23:04:41 +08:00
|
|
|
### Config file
|
|
|
|
|
|
|
|
location: $HOME/.adguardhome-sync.yaml
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# cron expression to run in daemon mode. (default; "" = runs only once)
|
|
|
|
cron: "*/10 * * * *"
|
|
|
|
|
2021-04-19 04:20:08 +08:00
|
|
|
# runs the synchronisation on startup
|
|
|
|
runOnStart: true
|
|
|
|
|
2024-01-08 05:03:21 +08:00
|
|
|
# If enabled, the synchronisation task will not fail on single errors, but will log the errors and continue
|
|
|
|
continueOnError: false
|
|
|
|
|
2021-03-28 23:04:41 +08:00
|
|
|
origin:
|
|
|
|
# url of the origin instance
|
|
|
|
url: https://192.168.1.2:3000
|
|
|
|
# apiPath: define an api path if other than "/control"
|
|
|
|
# insecureSkipVerify: true # disable tls check
|
|
|
|
username: username
|
|
|
|
password: password
|
2023-08-05 13:38:21 +08:00
|
|
|
# cookie: Origin-Cookie-Name=CCCOOOKKKIIIEEE
|
2021-03-28 23:04:41 +08:00
|
|
|
|
2024-01-14 20:29:36 +08:00
|
|
|
# replicas instances
|
2021-03-28 23:04:41 +08:00
|
|
|
replicas:
|
|
|
|
# url of the replica instance
|
|
|
|
- url: http://192.168.1.3
|
|
|
|
username: username
|
|
|
|
password: password
|
2023-08-05 13:38:21 +08:00
|
|
|
# cookie: Replica1-Cookie-Name=CCCOOOKKKIIIEEE
|
2021-03-28 23:04:41 +08:00
|
|
|
- url: http://192.168.1.4
|
|
|
|
username: username
|
|
|
|
password: password
|
2023-08-05 13:38:21 +08:00
|
|
|
# cookie: Replica2-Cookie-Name=CCCOOOKKKIIIEEE
|
|
|
|
# autoSetup: true # if true, AdGuardHome is automatically initialized.
|
2024-01-07 16:55:21 +08:00
|
|
|
# webURL: "https://some-other.url" # used in the web interface (default: <replica-url>
|
2021-03-29 02:39:19 +08:00
|
|
|
|
|
|
|
# Configure the sync API server, disabled if api port is 0
|
|
|
|
api:
|
|
|
|
# Port, default 8080
|
|
|
|
port: 8080
|
2023-08-05 13:38:21 +08:00
|
|
|
# if username and password are defined, basic auth is applied to the sync API
|
2021-03-29 02:39:19 +08:00
|
|
|
username: username
|
|
|
|
password: password
|
2024-01-07 16:55:21 +08:00
|
|
|
# enable api dark mode
|
|
|
|
darkMode: true
|
2021-03-29 02:39:19 +08:00
|
|
|
|
2021-11-01 15:56:12 +08:00
|
|
|
# Configure sync features; by default all features are enabled.
|
|
|
|
features:
|
2021-11-02 01:20:14 +08:00
|
|
|
generalSettings: true
|
|
|
|
queryLogConfig: true
|
|
|
|
statsConfig: true
|
|
|
|
clientSettings: true
|
|
|
|
services: true
|
|
|
|
filters: true
|
2021-11-01 15:56:12 +08:00
|
|
|
dhcp:
|
2021-11-02 01:20:14 +08:00
|
|
|
serverConfig: true
|
2021-11-01 15:56:12 +08:00
|
|
|
staticLeases: true
|
2021-11-02 01:20:14 +08:00
|
|
|
dns:
|
|
|
|
serverConfig: true
|
|
|
|
accessLists: true
|
|
|
|
rewrites: true
|
2021-03-28 23:04:41 +08:00
|
|
|
```
|
2021-04-19 00:28:35 +08:00
|
|
|
|
|
|
|
## Log Level
|
|
|
|
|
|
|
|
The log level can be set with the environment variable: LOG_LEVEL
|
|
|
|
|
|
|
|
The following log levels are supported (default: info)
|
|
|
|
|
|
|
|
- debug
|
|
|
|
- info
|
|
|
|
- warn
|
2022-05-06 02:25:20 +08:00
|
|
|
- error
|