mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
Compare commits
No commits in common. "master" and "V2.3.1" have entirely different histories.
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@ -7,10 +7,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.15.7
|
- name: Set up Go 1.13.6
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.15.7
|
go-version: 1.13.6
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
13
Dockerfile
13
Dockerfile
@ -2,8 +2,13 @@ FROM golang:alpine AS builder
|
|||||||
RUN mkdir /godns
|
RUN mkdir /godns
|
||||||
ADD . /godns/
|
ADD . /godns/
|
||||||
WORKDIR /godns
|
WORKDIR /godns
|
||||||
RUN CGO_ENABLED=0 go build -o godns cmd/godns/godns.go
|
RUN go build -o godns cmd/godns/godns.go
|
||||||
|
|
||||||
FROM gcr.io/distroless/base
|
FROM alpine
|
||||||
COPY --from=builder /godns/godns /godns
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
ENTRYPOINT ["/godns"]
|
RUN mkdir /usr/local/godns
|
||||||
|
COPY --from=builder /godns/godns /usr/local/godns
|
||||||
|
RUN chmod +x /usr/local/godns/godns
|
||||||
|
RUN rm -rf /var/cache/apk/*
|
||||||
|
WORKDIR /usr/local/godns
|
||||||
|
ENTRYPOINT ["./godns", "-c", "/usr/local/godns/config.json"]
|
||||||
|
6
Makefile
6
Makefile
@ -2,15 +2,15 @@
|
|||||||
BINARY=godns
|
BINARY=godns
|
||||||
# Builds the project
|
# Builds the project
|
||||||
build:
|
build:
|
||||||
GO111MODULE=on go build -ldflags "-X main.Version=${VERSION}" -o ${BINARY} cmd/godns/godns.go
|
GO111MODULE=on go build cmd/godns/godns.go -o ${BINARY} -ldflags "-X main.Version=${VERSION}"
|
||||||
# Installs our project: copies binaries
|
# Installs our project: copies binaries
|
||||||
install:
|
install:
|
||||||
GO111MODULE=on go install
|
GO111MODULE=on go install
|
||||||
image:
|
image:
|
||||||
# Build docker image
|
# Build docker image
|
||||||
go clean
|
go clean
|
||||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t timothyye/godns:${VERSION} . --push
|
docker buildx build --platform linux/amd64,linux/386,linux/arm64,linux/arm/v7 -t timothyye/godns:${VERSION} . --push
|
||||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t timothyye/godns:latest . --push
|
docker buildx build --platform linux/amd64,linux/386,linux/arm64,linux/arm/v7 -t timothyye/godns:latest . --push
|
||||||
release:
|
release:
|
||||||
# Clean
|
# Clean
|
||||||
go clean
|
go clean
|
||||||
|
401
README.md
401
README.md
@ -20,107 +20,70 @@
|
|||||||
[15]: https://img.shields.io/badge/cover.run-88.2%25-green.svg
|
[15]: https://img.shields.io/badge/cover.run-88.2%25-green.svg
|
||||||
[16]: https://cover.run/go/github.com/timothyye/godns
|
[16]: https://cover.run/go/github.com/timothyye/godns
|
||||||
|
|
||||||
[GoDNS](https://github.com/TimothyYe/godns) is a dynamic DNS (DDNS) client tool. It is a rewrite in [Go](https://golang.org) of my early [DynDNS](https://github.com/TimothyYe/DynDNS) open source project.
|
GoDNS is a dynamic DNS (DDNS) client tool, it is based on my early open source project: [DynDNS](https://github.com/TimothyYe/DynDNS).
|
||||||
|
|
||||||
Currently supports updating A records for subdomains. Doesn't support updating of root domains.
|
Now I rewrite [DynDNS](https://github.com/TimothyYe/DynDNS) by Golang and call it [GoDNS](https://github.com/TimothyYe/godns).
|
||||||
|
|
||||||
---
|
|
||||||
- [Supported DNS Providers](#supported-dns-providers)
|
|
||||||
- [Supported Platforms](#supported-platforms)
|
|
||||||
- [Pre-conditions](#pre-conditions)
|
|
||||||
- [Installation](#installation)
|
|
||||||
- [Usage](#usage)
|
|
||||||
- [Configuration](#configuration)
|
|
||||||
- [Overview](#overview)
|
|
||||||
- [Configuration properties](#configuration-properties)
|
|
||||||
- [Configuration examples](#configuration-examples)
|
|
||||||
- [Cloudflare](#cloudflare)
|
|
||||||
- [DNSPod](#dnspod)
|
|
||||||
- [Dreamhost](#dreamhost)
|
|
||||||
- [Google Domains](#google-domains)
|
|
||||||
- [AliDNS](#alidns)
|
|
||||||
- [DuckDNS](#duckdns)
|
|
||||||
- [No-IP](#no-ip)
|
|
||||||
- [HE.net](#henet)
|
|
||||||
- [Notifications](#notifications)
|
|
||||||
- [Email](#email)
|
|
||||||
- [Telegram](#telegram)
|
|
||||||
- [Slack](#slack)
|
|
||||||
- [Miscellaneous topics](#miscellaneous-topics)
|
|
||||||
- [IPv6 support](#ipv6-support)
|
|
||||||
- [Network interface IP address](#network-interface-ip-address)
|
|
||||||
- [SOCKS5 proxy support](#socks5-proxy-support)
|
|
||||||
- [Running GoDNS](#running-godns)
|
|
||||||
- [As a manual daemon](#as-a-manual-daemon)
|
|
||||||
- [As a managed daemon (with upstart)](#as-a-managed-daemon-with-upstart)
|
|
||||||
- [As a managed daemon (with systemd)](#as-a-managed-daemon-with-systemd)
|
|
||||||
- [As a Docker container](#as-a-docker-container)
|
|
||||||
- [As a Windows service](#as-a-windows-service)
|
|
||||||
- [Special Thanks](#special-thanks)
|
|
||||||
|
|
||||||
---
|
|
||||||
## Supported DNS Providers
|
## Supported DNS Providers
|
||||||
|
|
||||||
| Provider | IPv4 support | IPv6 support | Root Domain | Subdomains |
|
* Cloudflare ([https://cloudflare.com](https://cloudflare.com))
|
||||||
| ------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: |
|
* Google Domains ([https://domains.google](https://domains.google))
|
||||||
| [Cloudflare][cloudflare] | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
* DNSPod ([https://www.dnspod.cn/](https://www.dnspod.cn/))
|
||||||
| [Google Domains][google.domains] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
* HE.net (Hurricane Electric) ([https://dns.he.net/](https://dns.he.net/))
|
||||||
| [DNSPod][dnspod] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
* AliDNS ([https://help.aliyun.com/product/29697.html](https://help.aliyun.com/product/29697.html))
|
||||||
| [HE.net (Hurricane Electric)][he.net] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
* DuckDNS ([https://www.duckdns.org](https://www.duckdns.org))
|
||||||
| [AliDNS][alidns] | :white_check_mark: | :x: | :x: | :white_check_mark: |
|
* Dreamhost ([https://www.dreamhost.com](https://www.dreamhost.com))
|
||||||
| [DuckDNS][duckdns] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
* No-IP ([https://www.noip.com/](https://www.noip.com))
|
||||||
| [Dreamhost][dreamhost] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
|
||||||
| [No-IP][no-ip] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
|
||||||
|
|
||||||
[cloudflare]: https://cloudflare.com
|
|
||||||
[google.domains]: https://domains.google
|
|
||||||
[dnspod]: https://www.dnspod.cn
|
|
||||||
[he.net]: https://dns.he.net
|
|
||||||
[alidns]: https://help.aliyun.com/product/29697.html
|
|
||||||
[duckdns]: https://www.duckdns.org
|
|
||||||
[dreamhost]: https://www.dreamhost.com
|
|
||||||
[no-ip]: https://www.noip.com
|
|
||||||
|
|
||||||
Tip: You can follow this [issue](https://github.com/TimothyYe/godns/issues/76) to view the current status of DDNS for root domains.
|
|
||||||
|
|
||||||
## Supported Platforms
|
## Supported Platforms
|
||||||
|
|
||||||
* Linux
|
* Linux
|
||||||
* MacOS
|
* MacOS
|
||||||
* ARM Linux (Raspberry Pi, etc.)
|
* ARM Linux (Raspberry Pi, etc...)
|
||||||
* Windows
|
* Windows
|
||||||
* MIPS32 platform
|
* MIPS32 platform
|
||||||
|
|
||||||
To compile binaries for MIPS (mips or mipsle), run:
|
## MIPS32 platform
|
||||||
|
|
||||||
|
To compile binaries for MIPS (mips or mipsle):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
GOOS=linux GOARCH=mips/mipsle GOMIPS=softfloat go build -a
|
GOOS=linux GOARCH=mips/mipsle GOMIPS=softfloat go build -a
|
||||||
```
|
```
|
||||||
|
|
||||||
The binary can run on routers as well.
|
And the binary can run well on routers.
|
||||||
|
|
||||||
## Pre-conditions
|
## Pre-condition
|
||||||
|
|
||||||
To use GoDNS, it is assumed:
|
* Register and own a domain.
|
||||||
* You registered (now own) a domain
|
|
||||||
* Domain was delegated to a supported [DNS provider](#supported-dns-providers) (i.e. it has nameserver `NS` records pointing at a supported provider)
|
|
||||||
|
|
||||||
Alternatively, you can sign in to [DuckDNS](https://www.duckdns.org) (with a social account) and get a subdomain on the duckdns.org domain for free.
|
* Domain's nameserver points to [DNSPod](https://www.dnspod.cn/) or [HE.net](https://dns.he.net/) or [Cloudflare](https://www.cloudflare.com/) or [Google Domains](https://domains.google) or [AliDNS](https://dc.console.aliyun.com).
|
||||||
|
|
||||||
## Installation
|
* Or just register an account from [DuckDNS](https://www.duckdns.org/).
|
||||||
|
|
||||||
Build GoDNS by running (from the root of the repository):
|
## Get it
|
||||||
|
|
||||||
|
### Build it from source code
|
||||||
|
|
||||||
|
* Get source code from Github:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd cmd/godns # go to the GoDNS directory
|
git clone https://github.com/timothyye/godns.git
|
||||||
go get -v # get dependencies
|
|
||||||
go build # build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also download a compiled binary from the [releases](https://github.com/TimothyYe/godns/releases).
|
* Go into the godns directory, get related library and then build it:
|
||||||
## Usage
|
|
||||||
|
|
||||||
Print usage/help by running:
|
```bash
|
||||||
|
cd cmd/godns
|
||||||
|
go get -v
|
||||||
|
go build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Download from releases
|
||||||
|
|
||||||
|
Download compiled binaries from [releases](https://github.com/TimothyYe/godns/releases)
|
||||||
|
|
||||||
|
## Get help
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ ./godns -h
|
$ ./godns -h
|
||||||
@ -130,37 +93,74 @@ Usage of ./godns:
|
|||||||
-h Show help
|
-h Show help
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Config it
|
||||||
|
|
||||||
### Overview
|
* Get [config_sample.json](https://github.com/timothyye/godns/blob/master/config_sample.json) from Github.
|
||||||
|
* Rename it to **config.json**.
|
||||||
|
* Configure your provider, domain/subdomain info, username and password, etc.
|
||||||
|
* Configure the SMTP options if you want, a mail notification will sent to your mailbox once the IP is changed.
|
||||||
|
* Save it in the same directory of GoDNS, or use -c=your_conf_path command.
|
||||||
|
|
||||||
* Make a copy of [config_sample.json](./config_sample.json) and name it `config.json`
|
## Config fields
|
||||||
* Configure your provider, domain/subdomain info, credentials, etc.
|
|
||||||
* Configure a notification medium (e.g. SMTP to receive emails) to get notified when your IP address changes
|
|
||||||
* Place the file in the same directory of GoDNS or use the `-c=path/to/your/file.json` option
|
|
||||||
|
|
||||||
### Configuration properties
|
* provider: The providers that GoDNS supports, available values are: `Cloudflare`, `Google`, `DNSPod`, `AliDNS`, `HE`, `DuckDNS`, `Dreamhost`.
|
||||||
|
* email: Email or account name of your DNS provider.
|
||||||
|
* password: Password of your account.
|
||||||
|
* login_token: API token of your account.
|
||||||
|
* domains: Domains list, with your sub domains.
|
||||||
|
* ip_url: A site helps you to get your public IPv4 IP address.
|
||||||
|
* ipv6_url: A site helps you to get your public IPv6 address.
|
||||||
|
* ip_type: To configure GoDNS under IPv4 mode or IPv6 mode, available values are: `IPv4`, `IPv6`.
|
||||||
|
* interval: The interval `seconds` that GoDNS check your public IP.
|
||||||
|
* socks5_proxy: Socks5 proxy server.
|
||||||
|
* resolver: The address of the public DNS server. For example, to run GoDNS in `IPv4` mode, you can set resolver as `8.8.8.8`, to GoDNS in `IPv6` mode, you can set resolver as `2001:4860:4860::8888`.
|
||||||
|
|
||||||
* `provider` — One of the [supported provider to use](#supported-dns-providers): `Cloudflare`, `Google`, `DNSPod`, `AliDNS`, `HE`, `DuckDNS` or `Dreamhost`.
|
## IPv6 support
|
||||||
* `email` — Email or account name of the DNS provider.
|
|
||||||
* `password` — Password of the DNS provider.
|
|
||||||
* `login_token` — API token of the DNS provider.
|
|
||||||
* `domains` — Domains list, with your sub domains.
|
|
||||||
* `ip_url` — A URL for fetching one's public IPv4 address.
|
|
||||||
* `ipv6_url` — A URL for fetching one's public IPv6 address.
|
|
||||||
* `ip_type` — Switch deciding if IPv4 or IPv6 should be used (when [supported](#supported-dns-providers)). Available values: `IPv4` or `IPv6`.
|
|
||||||
* `interval` — How often (in seconds) the public IP should be updated.
|
|
||||||
* `socks5_proxy` — Socks5 proxy server.
|
|
||||||
* `resolver` — Address of a public DNS server to use. For instance to use [Google's public DNS](https://developers.google.com/speed/public-dns/docs/using), you can set `8.8.8.8` when using GoDNS in IPv4 mode or `2001:4860:4860::8888` in IPv6 mode.
|
|
||||||
|
|
||||||
### Configuration examples
|
Supported provider(s):
|
||||||
|
* Cloudflare
|
||||||
|
* DNSPod
|
||||||
|
* Dreamhost
|
||||||
|
* DuckDNS
|
||||||
|
* Google Domains
|
||||||
|
* HE.net
|
||||||
|
* No-IP
|
||||||
|
|
||||||
#### Cloudflare
|
To enable the `IPv6` support of GoDNS, there are 2 solutions you can choose:
|
||||||
|
* Get IPv6 address online
|
||||||
|
* Get IPv6 address from your network interface
|
||||||
|
|
||||||
|
To get IPv6 address online:
|
||||||
|
* Set the `ip_type` as `IPv6`, and make sure the `ipv6_url` is configured.
|
||||||
|
* Add one `AAAA` record to your provider.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"domains": [
|
||||||
|
{
|
||||||
|
"domain_name": "example.com",
|
||||||
|
"sub_domains": [
|
||||||
|
"ipv6"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resolver": "2001:4860:4860::8888",
|
||||||
|
"ipv6_url": "https://api-ipv6.ip.sb/ip",
|
||||||
|
"ip_type": "IPv6"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
To get IPv6 address from your interface:
|
||||||
|
|
||||||
|
It is quite simple, just left "ip_url" & "ipv6_url" as empty. Please note that an IPv6 address configured for your interface is the prerequisite for this feature.
|
||||||
|
|
||||||
|
### Config example for Cloudflare
|
||||||
|
|
||||||
For Cloudflare, you need to provide the email & Global API Key as password (or to use the API token) and config all the domains & subdomains.
|
For Cloudflare, you need to provide the email & Global API Key as password (or to use the API token) and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
* Using email & Global API Key
|
||||||
<summary>Using email & Global API Key</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -181,10 +181,8 @@ For Cloudflare, you need to provide the email & Global API Key as password (or t
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
* Using the API Token
|
||||||
<summary>Using the API Token</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -204,15 +202,11 @@ For Cloudflare, you need to provide the email & Global API Key as password (or t
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### DNSPod
|
### Config example for DNSPod
|
||||||
|
|
||||||
For DNSPod, you need to provide your API Token(you can create it [here](https://www.dnspod.cn/console/user/security)), and config all the domains & subdomains.
|
For DNSPod, you need to provide your API Token(you can create it [here](https://www.dnspod.cn/console/user/security)), and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "DNSPod",
|
"provider": "DNSPod",
|
||||||
@ -232,15 +226,11 @@ For DNSPod, you need to provide your API Token(you can create it [here](https://
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### Dreamhost
|
### Config example for Dreamhost
|
||||||
|
|
||||||
For Dreamhost, you need to provide your API Token(you can create it [here](https://panel.dreamhost.com/?tree=home.api)), and config all the domains & subdomains.
|
For Dreamhost, you need to provide your API Token(you can create it [here](https://panel.dreamhost.com/?tree=home.api)), and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "Dreamhost",
|
"provider": "Dreamhost",
|
||||||
@ -261,15 +251,11 @@ For Dreamhost, you need to provide your API Token(you can create it [here](https
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### Google Domains
|
### Config example for Google Domains
|
||||||
|
|
||||||
For Google Domains, you need to provide email & password, and config all the domains & subdomains.
|
For Google Domains, you need to provide email & password, and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "Google",
|
"provider": "Google",
|
||||||
@ -289,15 +275,11 @@ For Google Domains, you need to provide email & password, and config all the dom
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### AliDNS
|
### Config example for AliDNS
|
||||||
|
|
||||||
For AliDNS, you need to provide `AccessKeyID` & `AccessKeySecret` as `email` & `password`, and config all the domains & subdomains.
|
For AliDNS, you need to provide `AccessKeyID` & `AccessKeySecret` as `email` & `password`, and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "AliDNS",
|
"provider": "AliDNS",
|
||||||
@ -318,15 +300,11 @@ For AliDNS, you need to provide `AccessKeyID` & `AccessKeySecret` as `email` & `
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### DuckDNS
|
### Config example for DuckDNS
|
||||||
|
|
||||||
For DuckDNS, only need to provide the `token`, config 1 default domain & subdomains.
|
For DuckDNS, only need to provide the `token`, config 1 default domain & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "DuckDNS",
|
"provider": "DuckDNS",
|
||||||
@ -346,12 +324,8 @@ For DuckDNS, only need to provide the `token`, config 1 default domain & subdoma
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### No-IP
|
### Config example for No-IP
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -371,15 +345,11 @@ For DuckDNS, only need to provide the `token`, config 1 default domain & subdoma
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
#### HE.net
|
### Config example for HE.net
|
||||||
|
|
||||||
For HE, email is not needed, just fill DDNS key to password, and config all the domains & subdomains.
|
For HE, email is not needed, just fill DDNS key to password, and config all the domains & subdomains.
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"provider": "HE",
|
"provider": "HE",
|
||||||
@ -399,31 +369,36 @@ For HE, email is not needed, just fill DDNS key to password, and config all the
|
|||||||
"socks5_proxy": ""
|
"socks5_proxy": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
### HE.net DDNS configuration
|
||||||
<summary>Provider configuration</summary>
|
|
||||||
|
|
||||||
Add a new "A record" and make sure that "Enable entry for dynamic dns" is checked:
|
Add a new "A record", make sure that "Enable entry for dynamic dns" is checked:
|
||||||
|
|
||||||
<img src="./snapshots/he1.png" width="640" />
|
<img src="https://github.com/TimothyYe/godns/blob/master/snapshots/he1.png?raw=true" width="640" />
|
||||||
|
|
||||||
Fill in your own DDNS key or generate a random DDNS key for this new created "A record":
|
Fill your own DDNS key or generate a random DDNS key for this new created "A record":
|
||||||
|
|
||||||
<img src="./snapshots/he2.png" width="640" />
|
<img src="https://github.com/TimothyYe/godns/blob/master/snapshots/he2.png?raw=true" width="640" />
|
||||||
|
|
||||||
Remember the DDNS key and set it in the `password` property in the configuration file.
|
Remember the DDNS key and fill it as password to the config.json.
|
||||||
|
|
||||||
__NOTICE__: If you have multiple domains or subdomains, make sure their DDNS key are the same.
|
__NOTICE__: If you have multiple domains or subdomains, make sure their DDNS key are the same.
|
||||||
</details>
|
|
||||||
|
|
||||||
### Notifications
|
### Get an IP address from the interface
|
||||||
|
|
||||||
GoDNS can send a notification each time the IP changes.
|
For some reasons if you want to get an IP directly from the interface, say `eth0` for Linux or `Local Area Connection` for Windows, update config file like this:
|
||||||
|
|
||||||
#### Email
|
```json
|
||||||
|
"ip_url": "",
|
||||||
|
"ip_interface": "eth0",
|
||||||
|
```
|
||||||
|
|
||||||
Emails are sent over [SMTP](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol). Update your configuration with the following snippet:
|
If you set both `ip_url` and `ip_interface`, it first tries to get an IP address online, and if not succeed, gets
|
||||||
|
an IP address from the interface as a fallback.
|
||||||
|
|
||||||
|
### Email notification support
|
||||||
|
|
||||||
|
Update config file and provide your SMTP options, a notification mail will be sent to your mailbox once the IP is changed and updated.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"notify": {
|
"notify": {
|
||||||
@ -438,13 +413,13 @@ Emails are sent over [SMTP](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_P
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Each time the IP changes, you will receive an email like that:
|
Notification mail example:
|
||||||
|
|
||||||
<img src="https://github.com/TimothyYe/godns/blob/master/snapshots/mail.png?raw=true" />
|
<img src="https://github.com/TimothyYe/godns/blob/master/snapshots/mail.png?raw=true" />
|
||||||
|
|
||||||
#### Telegram
|
### Telegram notification support
|
||||||
|
|
||||||
To receive a [Telegram](https://telegram.org/) message each time the IP changes, update your configuration with the following snippet:
|
Update config file and provide your Telegram options, a notification message will be sent to your telegram channel once the IP is changed and updated.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"notify": {
|
"notify": {
|
||||||
@ -457,12 +432,11 @@ To receive a [Telegram](https://telegram.org/) message each time the IP changes,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Markdown is supported in message template, and use `%0A` for newline.
|
||||||
|
|
||||||
The `message_template` property supports [markdown](https://www.markdownguide.org). New lines needs to be escaped with `%0A`.
|
### Slack notification support
|
||||||
|
|
||||||
#### Slack
|
Update config file and provide your Slack options, a notification message will be sent to your slack channel once the IP is changed and updated.
|
||||||
|
|
||||||
To receive a [Slack](https://slack.com) message each time the IP changes, update your configuration with the following snippet:
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"notify": {
|
"notify": {
|
||||||
@ -475,143 +449,82 @@ To receive a [Slack](https://slack.com) message each time the IP changes, update
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Markdown is supported in message template, and use `\n` for newline.
|
||||||
|
|
||||||
The `message_template` property supports [markdown](https://www.markdownguide.org). New lines needs to be escaped with `\n`.
|
|
||||||
|
|
||||||
### Miscellaneous topics
|
### SOCKS5 proxy support
|
||||||
|
|
||||||
#### IPv6 support
|
You can also use SOCKS5 proxy, just fill SOCKS5 address to the ```socks5_proxy``` item:
|
||||||
|
|
||||||
Most of the [providers](#supported-dns-providers) support IPv6.
|
|
||||||
|
|
||||||
To enable the `IPv6` support of GoDNS, there are two solutions to choose from:
|
|
||||||
|
|
||||||
1. Use an online service to lookup the external IPv6
|
|
||||||
|
|
||||||
For that:
|
|
||||||
|
|
||||||
- Set the `ip_type` as `IPv6`, and make sure the `ipv6_url` is configured
|
|
||||||
- Create an `AAAA` record instead of an `A` record in your DNS provider
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Configuration example</summary>
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
|
||||||
"domains": [
|
|
||||||
{
|
|
||||||
"domain_name": "example.com",
|
|
||||||
"sub_domains": [
|
|
||||||
"ipv6"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"resolver": "2001:4860:4860::8888",
|
|
||||||
"ipv6_url": "https://api-ipv6.ip.sb/ip",
|
|
||||||
"ip_type": "IPv6"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
|
|
||||||
2. Let GoDNS find the IPv6 of the network interface of the machine it is running on (more on that [later](#network-interface-ip-address)).
|
|
||||||
|
|
||||||
For this to happen, just leave `ip_url` and `ipv6_url` empty.
|
|
||||||
|
|
||||||
Note that the network interface must be configured with an IPv6 for this to work.
|
|
||||||
|
|
||||||
#### Network interface IP address
|
|
||||||
|
|
||||||
For some reasons if you want to get the IP address associated to a network interface (instead of performing an online lookup), you can specify it in the configuration file this way:
|
|
||||||
|
|
||||||
```json
|
|
||||||
...
|
|
||||||
"ip_url": "",
|
|
||||||
"ip_interface": "interface-name",
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
With `interface-name` replaced by the name of the network interface, e.g. `eth0` on Linux or `Local Area Connection` on Windows.
|
|
||||||
|
|
||||||
Note: If `ip_url` is also specified, it will be used to perform an online lookup first and the network interface IP will be used as a fallback in case of failure.
|
|
||||||
|
|
||||||
#### SOCKS5 proxy support
|
|
||||||
|
|
||||||
You can make all remote calls go through a [SOCKS5 proxy](https://en.wikipedia.org/wiki/SOCKS#SOCKS5) by specifying it in the configuration file this way:
|
|
||||||
|
|
||||||
```json
|
|
||||||
...
|
|
||||||
"socks5_proxy": "127.0.0.1:7070"
|
"socks5_proxy": "127.0.0.1:7070"
|
||||||
"use_proxy": true
|
"use_proxy": true
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running GoDNS
|
Now all the queries will go through the specified SOCKS5 proxy.
|
||||||
|
|
||||||
There are few ways to run GoDNS.
|
## Run it as a daemon manually
|
||||||
|
|
||||||
### As a manual daemon
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nohup ./godns &
|
nohup ./godns &
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: when the program stops, it will not be restarted.
|
## Run it as a daemon, manage it via Upstart
|
||||||
|
|
||||||
### As a managed daemon (with upstart)
|
* Install `upstart` first
|
||||||
|
* Copy `./upstart/godns.conf` to `/etc/init`
|
||||||
1. Install `upstart` first (if not available already)
|
* Start it as a system service:
|
||||||
2. Copy `./upstart/godns.conf` to `/etc/init` (and tweak it to your needs)
|
|
||||||
3. Start the service:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo start godns
|
sudo start godns
|
||||||
```
|
```
|
||||||
|
|
||||||
### As a managed daemon (with systemd)
|
## Run it as a daemon, manage it via Systemd
|
||||||
|
|
||||||
1. Install `systemd` first (it not available already)
|
* Modify `./systemd/godns.service` and config it.
|
||||||
2. Copy `./systemd/godns.service` to `/lib/systemd/system` (and tweak it to your needs)
|
* Copy `./systemd/godns.service` to `/lib/systemd/system`
|
||||||
3. Start the service:
|
* Start it as a systemd service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl enable godns
|
sudo systemctl enable godns
|
||||||
sudo systemctl start godns
|
sudo systemctl start godns
|
||||||
```
|
```
|
||||||
|
|
||||||
### As a Docker container
|
## Run it with docker
|
||||||
|
|
||||||
With `/path/to/config.json` your local configuration file, run:
|
Now godns supports to run in docker.
|
||||||
|
|
||||||
|
* Get [config_sample.json](https://github.com/timothyye/godns/blob/master/config_sample.json) from Github.
|
||||||
|
* Rename it to **config.json**.
|
||||||
|
* Run GoDNS with docker:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run \
|
docker run -d --name godns --restart=always \
|
||||||
-d --name godns --restart=always \
|
-v /path/to/config.json:/usr/local/godns/config.json timothyye/godns:latest
|
||||||
-v /path/to/config.json:/config.json \
|
|
||||||
timothyye/godns:latest
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### As a Windows service
|
## Run it as a Windows service
|
||||||
|
|
||||||
1. Download the latest version of [NSSM](https://nssm.cc/download)
|
After creating your config.json file:
|
||||||
|
|
||||||
2. In an administrative prompt, from the folder where NSSM was downloaded, e.g. `C:\Downloads\nssm\` **win64**, run:
|
* Get the latest [NSSM](https://nssm.cc/download) for create a windows service.
|
||||||
|
* Open the command prompt (as administrator) in the folder where you downloaded NSSM (e.g. C:\Downloads\nssm\ **win64**) and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
nssm install YOURSERVICENAME
|
nssm install YOURSERVICENAME
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Follow the interface to configure the service. In the "Application" tab just indicate where the `godns.exe` file is. Optionally you can also define a description on the "Details" tab and define a log file on the "I/O" tab. Finish by clicking on the "Install service" button.
|
You will have an interface to configure your service, it is very simple in the "Application" tab just indicate where your `godns.exe` file is. Optionally you can also define a description on the "Details" tab and define a log file on the "I/O" tab.
|
||||||
|
|
||||||
4. The service will now start along Windows.
|
* Finish using the "Install service" button.
|
||||||
|
* Done. Now whenever windows start your service will be loaded.
|
||||||
Note: you can uninstall the service by running:
|
* To uninstall:
|
||||||
|
|
||||||
```
|
```
|
||||||
nssm remove YOURSERVICENAME
|
nssm remove YOURSERVICENAME
|
||||||
```
|
```
|
||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
<img src="https://i.imgur.com/xhe5RLZ.jpg" width="80px" align="right" />
|
<img src="https://i.imgur.com/xhe5RLZ.jpg" width="80px" align="right" />
|
||||||
|
|
||||||
Thanks JetBrains for sponsoring this project with [free open source license](https://www.jetbrains.com/community/opensource/).
|
Thanks JetBrains for sponsoring this project with [free open source license](https://www.jetbrains.com/community/opensource/).
|
||||||
|
@ -128,9 +128,6 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
|||||||
|
|
||||||
// Check if record is present in domain conf
|
// Check if record is present in domain conf
|
||||||
func recordTracked(domain *godns.Domain, record *DNSRecord) bool {
|
func recordTracked(domain *godns.Domain, record *DNSRecord) bool {
|
||||||
if record.Name == domain.DomainName {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
for _, subDomain := range domain.SubDomains {
|
for _, subDomain := range domain.SubDomains {
|
||||||
sd := fmt.Sprintf("%s.%s", subDomain, domain.DomainName)
|
sd := fmt.Sprintf("%s.%s", subDomain, domain.DomainName)
|
||||||
if record.Name == sd {
|
if record.Name == sd {
|
||||||
@ -166,7 +163,7 @@ func (handler *Handler) getZone(domain string) string {
|
|||||||
|
|
||||||
var z ZoneResponse
|
var z ZoneResponse
|
||||||
|
|
||||||
req, client := handler.newRequest("GET", fmt.Sprintf("/zones?name=%s", domain), nil)
|
req, client := handler.newRequest("GET", "/zones", nil)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Request error:", err.Error())
|
log.Println("Request error:", err.Error())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user