From 3e2a3afc529fe622d44348e48d4c89d81269bfec Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Mon, 15 Oct 2018 16:02:19 +0300 Subject: [PATCH 1/2] Rename from 'Adguard DNS' to 'AdGuard Home'. --- .gitignore | 4 +-- Makefile | 6 ++-- README.md | 38 +++++++++++----------- client/src/components/Settings/Upstream.js | 2 +- client/src/helpers/constants.js | 4 +-- config.go | 2 +- control.go | 6 ++-- coredns.go | 2 +- coredns_plugin/coredns_plugin.go | 2 +- coredns_plugin/querylog.go | 2 +- coredns_plugin/querylog_top.go | 2 +- dnsfilter/README.md | 8 ++--- version.json | 14 ++++---- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index 62061c74..4f695bdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .DS_Store .vscode debug -/AdguardDNS -/AdguardDNS.yaml +/AdGuardHome +/AdGuardHome.yaml /build/ /client/node_modules/ /coredns diff --git a/Makefile b/Makefile index d2cb0b11..c5421e97 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GOPATH := $(mkfile_dir)/build/gopath JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js') STATIC = build/static/index.html -TARGET=AdguardDNS +TARGET=AdGuardHome .PHONY: all build clean all: build @@ -23,10 +23,10 @@ $(STATIC): $(JSFILES) client/node_modules $(TARGET): $(STATIC) *.go coredns_plugin/*.go dnsfilter/*.go mkdir -p $(GOPATH)/src/github.com/AdguardTeam - if [ ! -h $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS ]; then rm -rf $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS && ln -fs ../../../../.. $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS; fi + if [ ! -h $(GOPATH)/src/github.com/AdguardTeam/AdGuardHome ]; then rm -rf $(GOPATH)/src/github.com/AdguardTeam/AdGuardHome && ln -fs ../../../../.. $(GOPATH)/src/github.com/AdguardTeam/AdGuardHome; fi GOPATH=$(GOPATH) go get -v -d . GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/... - mkdir -p $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS/build/static ## work around packr bug + mkdir -p $(GOPATH)/src/github.com/AdguardTeam/AdGuardHome/build/static ## work around packr bug cd $(GOPATH)/src/github.com/prometheus/client_golang && git reset --hard v0.8.0 perl -0777 -p -i.bak -e 's/pprofOnce.Do\(func\(\) {(.*)}\)/\1/ms' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go perl -0777 -p -i.bak -e 's/c.OnShutdown/c.OnRestart/' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go diff --git a/README.md b/README.md index ef48afbe..88b12c69 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -[![Build Status](https://travis-ci.org/AdguardTeam/AdguardDNS.svg)](https://travis-ci.org/AdguardTeam/AdguardDNS) +[![Build Status](https://travis-ci.org/AdguardTeam/AdGuardHome.svg)](https://travis-ci.org/AdguardTeam/AdGuardHome) -# Self-hosted AdGuard DNS +# AdGuard Home -AdGuard DNS is an alternative way to block ads, trackers and phishing websites, and also a parental control instrument. +AdGuard Home is an alternative way to block ads, trackers and phishing websites, and also a parental control instrument. -## How does AdGuard DNS work? +## How does AdGuard Home work? -If you configure your network to use this DNS server, every time a website sends an ad or phishing request, our server sends back a null ("empty") response. AdGuard has a database of domain names that serve for an ad, tracking or phishing purposes (and adult content, in case of parental control mode), and this database is regularly updated. +It works as a DNS server, if you configure your network to use this DNS server, every time a website sends an ad or phishing request, our server sends back a null ("empty") response. AdGuard has a database of domain names that serve for an ad, tracking or phishing purposes (and adult content, in case of parental control mode), and this database is regularly updated. ## How is this different from public AdGuard DNS servers? -Running your own AdGuard DNS offers you more options: +Running your own AdGuard Home offers you more options: * Enable/disable ad blocking on the fly. * Enable/disable blocking of phishing and malware websites. * Enable/disable blocking of websites with adult content. @@ -18,7 +18,7 @@ Running your own AdGuard DNS offers you more options: * See DNS query log — it shows what requests were sent by which clients and why a request was blocked. * Add your own custom filtering rules. -This repository describes how to set up and run your self-hosted instance of AdGuard DNS — it comes with a web dashboard that can be accessed via browser to control the DNS server and change its settings, it also allows to add your own filters written in both "hosts" and AdGuard syntaxes. +This repository describes how to set up and run your self-hosted instance of AdGuard Home — it comes with a web dashboard that can be accessed via browser to control the DNS server and change its settings, it also allows to add your own filters written in both "hosts" and AdGuard syntaxes. If this seems too complicated, you can always use our public AdGuard DNS servers — they are running the same code as in this repository and provide the same ad blocking/phishing protection/parental control functionality — https://adguard.com/en/adguard-dns/overview.html @@ -26,33 +26,33 @@ If this seems too complicated, you can always use our public AdGuard DNS servers ### Mac -Download this file: [AdguardDNS_0.1_MacOS.zip](https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_MacOS.zip), then unpack it and follow ["How to run"](#how-to-run) instructions below. +Download this file: [AdGuardHome_0.1_MacOS.zip](https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdGuardHome_0.1_MacOS.zip), then unpack it and follow ["How to run"](#how-to-run) instructions below. ### Linux 64-bit Intel -Download this file: [AdguardDNS_0.1_linux_amd64.tar.gz](https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_amd64.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. +Download this file: [AdGuardHome_0.1_linux_amd64.tar.gz](https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdGuardHome_0.1_linux_amd64.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. ### Linux 32-bit Intel -Download this file: [AdguardDNS_0.1_linux_386.tar.gz](https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_386.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. +Download this file: [AdGuardHome_0.1_linux_386.tar.gz](https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdGuardHome_0.1_linux_386.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. ### Raspberry Pi (32-bit ARM) -Download this file: [AdguardDNS_0.1_linux_arm.tar.gz](https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_arm.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. +Download this file: [AdGuardHome_0.1_linux_arm.tar.gz](https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdGuardHome_0.1_linux_arm.tar.gz), then unpack it and follow ["How to run"](#how-to-run) instructions below. ## How to run DNS works on port 53, which requires superuser privileges. Therefore, you need to run it with `sudo` in terminal: ```bash -sudo ./AdguardDNS +sudo ./AdGuardHome ``` -Now open the browser and navigate to http://localhost:3000/ to control your AdGuard DNS server. +Now open the browser and navigate to http://localhost:3000/ to control your AdGuard Home service. ### Running without superuser -You can run AdGuard DNS without superuser privileges, but you need to instruct it to use a different port rather than 53. You can do that by editing `AdguardDNS.yaml` and finding these two lines: +You can run AdGuard Home without superuser privileges, but you need to instruct it to use a different port rather than 53. You can do that by editing `AdGuardHome.yaml` and finding these two lines: ```yaml coredns: @@ -65,7 +65,7 @@ If the file does not exist, create it in the same folder, type these two lines d ### Additional configuration -Upon the first execution, a file named `AdguardDNS.yaml` will be created, with default values written in it. You can modify the file while your AdGuard DNS is not running. Otherwise, any changes to the file will be lost because the running program will overwrite them. +Upon the first execution, a file named `AdGuardHome.yaml` will be created, with default values written in it. You can modify the file while your AdGuard Home service is not running. Otherwise, any changes to the file will be lost because the running program will overwrite them. Settings are stored in [YAML format](https://en.wikipedia.org/wiki/YAML), possible parameters that you can configure are listed below: @@ -109,15 +109,15 @@ brew install go node Open Terminal and execute these commands: ```bash -git clone https://github.com/AdguardTeam/AdguardDNS -cd AdguardDNS +git clone https://github.com/AdguardTeam/AdGuardHome +cd AdGuardHome make ``` ## Contributing -You are welcome to fork this repository, make your changes and submit a pull request — https://github.com/AdguardTeam/AdguardDNS/pulls +You are welcome to fork this repository, make your changes and submit a pull request — https://github.com/AdguardTeam/AdGuardHome/pulls ## Reporting issues -If you run into any problem or have a suggestion, head to [this page](https://github.com/AdguardTeam/AdguardDNS/issues) and click on the `New issue` button. +If you run into any problem or have a suggestion, head to [this page](https://github.com/AdguardTeam/AdGuardHome/issues) and click on the `New issue` button. diff --git a/client/src/components/Settings/Upstream.js b/client/src/components/Settings/Upstream.js index 80d32311..cbcc421d 100644 --- a/client/src/components/Settings/Upstream.js +++ b/client/src/components/Settings/Upstream.js @@ -27,7 +27,7 @@ export default class Upstream extends Component { return (
diff --git a/client/src/helpers/constants.js b/client/src/helpers/constants.js index 58c85380..ff15ea93 100644 --- a/client/src/helpers/constants.js +++ b/client/src/helpers/constants.js @@ -17,6 +17,6 @@ export const STATUS_COLORS = { }; export const REPOSITORY = { - URL: 'https://github.com/AdguardTeam/AdguardDNS', - TRACKERS_DB: 'https://github.com/AdguardTeam/AdguardDNS/tree/master/client/src/helpers/trackers/adguard.json', + URL: 'https://github.com/AdguardTeam/AdGuardHome', + TRACKERS_DB: 'https://github.com/AdguardTeam/AdGuardHome/tree/master/client/src/helpers/trackers/adguard.json', }; diff --git a/config.go b/config.go index 9218526b..34b5a95b 100644 --- a/config.go +++ b/config.go @@ -62,7 +62,7 @@ var defaultDNS = []string{"tls://1.1.1.1", "tls://1.0.0.1"} // initialize to default values, will be changed later when reading config or parsing command line var config = configuration{ - ourConfigFilename: "AdguardDNS.yaml", + ourConfigFilename: "AdGuardHome.yaml", BindPort: 3000, BindHost: "127.0.0.1", CoreDNS: coreDNSConfig{ diff --git a/control.go b/control.go index d6b1eee2..0c895b7e 100644 --- a/control.go +++ b/control.go @@ -15,8 +15,8 @@ import ( "strings" "time" - coredns_plugin "github.com/AdguardTeam/AdguardDNS/coredns_plugin" - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/miekg/dns" "gopkg.in/asaskevich/govalidator.v4" ) @@ -29,7 +29,7 @@ var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) var versionCheckJSON []byte var versionCheckLastTime time.Time -const versionCheckURL = "https://adguardteam.github.io/AdguardDNS/version.json" +const versionCheckURL = "https://adguardteam.github.io/AdGuardHome/version.json" const versionCheckPeriod = time.Hour * 8 var client = &http.Client{ diff --git a/coredns.go b/coredns.go index 2c1f292d..fe3415a2 100644 --- a/coredns.go +++ b/coredns.go @@ -6,7 +6,7 @@ import ( "sync" // Include all plugins. - _ "github.com/AdguardTeam/AdguardDNS/coredns_plugin" + _ "github.com/AdguardTeam/AdGuardHome/coredns_plugin" _ "github.com/coredns/coredns/plugin/auto" _ "github.com/coredns/coredns/plugin/autopath" _ "github.com/coredns/coredns/plugin/bind" diff --git a/coredns_plugin/coredns_plugin.go b/coredns_plugin/coredns_plugin.go index 8316d687..6d51b217 100644 --- a/coredns_plugin/coredns_plugin.go +++ b/coredns_plugin/coredns_plugin.go @@ -12,7 +12,7 @@ import ( "sync" "time" - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/metrics" diff --git a/coredns_plugin/querylog.go b/coredns_plugin/querylog.go index b72d1719..34a23bab 100644 --- a/coredns_plugin/querylog.go +++ b/coredns_plugin/querylog.go @@ -14,7 +14,7 @@ import ( "sync" "time" - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/coredns/coredns/plugin/pkg/response" "github.com/miekg/dns" ) diff --git a/coredns_plugin/querylog_top.go b/coredns_plugin/querylog_top.go index 92f4ce9f..78cedd7a 100644 --- a/coredns_plugin/querylog_top.go +++ b/coredns_plugin/querylog_top.go @@ -14,7 +14,7 @@ import ( "sync" "time" - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "github.com/bluele/gcache" "github.com/miekg/dns" ) diff --git a/dnsfilter/README.md b/dnsfilter/README.md index fde33c65..3b90e004 100644 --- a/dnsfilter/README.md +++ b/dnsfilter/README.md @@ -1,9 +1,9 @@ -# AdGuard DNS Go library +# AdGuard Home's DNS filtering go library Example use: ```bash [ -z "$GOPATH" ] && export GOPATH=$HOME/go -go get -d github.com/AdguardTeam/AdguardDNS/dnsfilter +go get -d github.com/AdguardTeam/AdGuardHome/dnsfilter ``` Create file filter.go @@ -11,7 +11,7 @@ Create file filter.go package main import ( - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "log" ) @@ -48,7 +48,7 @@ You can also enable checking against AdGuard's SafeBrowsing: package main import ( - "github.com/AdguardTeam/AdguardDNS/dnsfilter" + "github.com/AdguardTeam/AdGuardHome/dnsfilter" "log" ) diff --git a/version.json b/version.json index 59d4ae7c..83732216 100644 --- a/version.json +++ b/version.json @@ -1,11 +1,11 @@ { "version": "v0.1", - "announcement": "AdGuard DNS v0.1 is now available!", - "announcement_url": "https://github.com/AdguardTeam/AdguardDNS/releases/tag/v0.1", - "download_darwin_amd64": "https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_MacOS.zip", - "download_linux_amd64": "https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_amd64.tar.gz", - "download_linux_386": "https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_386.tar.gz", - "download_linux_arm": "https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_arm.tar.gz", - "download_linux_arm64": "https://github.com/AdguardTeam/AdguardDNS/releases/download/v0.1/AdguardDNS_0.1_linux_arm64.tar.gz", + "announcement": "AdGuard Home v0.1 is now available!", + "announcement_url": "https://github.com/AdguardTeam/AdGuardHome/releases/tag/v0.1", + "download_darwin_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdguardDNS_0.1_MacOS.zip", + "download_linux_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdguardDNS_0.1_linux_amd64.tar.gz", + "download_linux_386": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdguardDNS_0.1_linux_386.tar.gz", + "download_linux_arm": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdguardDNS_0.1_linux_arm.tar.gz", + "download_linux_arm64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.1/AdguardDNS_0.1_linux_arm64.tar.gz", "selfupdate_min_version": "v0.0" } \ No newline at end of file From 1af11c4e45e13bcbeb9fe37f7867760f09ae8c2b Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Mon, 15 Oct 2018 16:13:03 +0300 Subject: [PATCH 2/2] Name migration -- rename config from AdguardDNS.yaml to AdGuardHome.yaml It's done only if user didn't specify it in parameters and target filename doesn't exist yet. --- app.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/app.go b/app.go index 0f33b112..90a3c1de 100644 --- a/app.go +++ b/app.go @@ -28,6 +28,8 @@ func main() { config.ourBinaryDir = filepath.Dir(executable) } + doConfigRename := true + // config can be specified, which reads options from there, but other command line flags have to override config values // therefore, we must do it manually instead of using a lib { @@ -96,9 +98,18 @@ func main() { } } if configFilename != nil { + // config was manually specified, don't do anything + doConfigRename = false config.ourConfigFilename = *configFilename } + if doConfigRename { + err := renameOldConfigIfNeccessary() + if err != nil { + panic(err) + } + } + err := askUsernamePasswordIfPossible() if err != nil { log.Fatal(err) @@ -229,3 +240,29 @@ func askUsernamePasswordIfPossible() error { config.AuthPass = password return nil } + +func renameOldConfigIfNeccessary() error { + oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml") + _, err := os.Stat(oldConfigFile) + if os.IsNotExist(err) { + // do nothing, file doesn't exist + trace("File %s doesn't exist, nothing to do", oldConfigFile) + return nil + } + + newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) + _, err = os.Stat(newConfigFile) + if !os.IsNotExist(err) { + // do nothing, file doesn't exist + trace("File %s already exists, will not overwrite", newConfigFile) + return nil + } + + err = os.Rename(oldConfigFile, newConfigFile) + if err != nil { + log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err) + return err + } + + return nil +}