Skip to content

Commit d001308

Browse files
authored
Add Bark notification support. (#278)
* Add Bark notification support. * tidy up README * Add basic auth params for Bark notification
1 parent 1a276f2 commit d001308

File tree

7 files changed

+255
-35
lines changed

7 files changed

+255
-35
lines changed

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[13]: https://godoc.org/github.com/TimothyYe/godns?status.svg
1919
[14]: https://godoc.org/github.com/TimothyYe/godns
2020

21-
[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.
21+
[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.
2222

2323
[查看中文帮助文档](README_CN.md)
2424

@@ -62,6 +62,7 @@
6262
- [Slack](#slack)
6363
- [Discord](#discord)
6464
- [Pushover](#pushover)
65+
- [Bark](#bark)
6566
- [Webhook](#webhook)
6667
- [Webhook with HTTP GET request](#webhook-with-http-get-request)
6768
- [Webhook with HTTP POST request](#webhook-with-http-post-request)
@@ -112,7 +113,7 @@
112113
| [Hetzner][hetzner] | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
113114
| [OVH][ovh] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
114115
| [Dynu][dynu] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
115-
| [IONOS][ionos] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
116+
| [IONOS][ionos] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
116117
| [TransIP][transip] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
117118

118119
[cloudflare]: https://cloudflare.com
@@ -352,7 +353,6 @@ For DigitalOcean, you need to provide an API Token with the `domain` scopes (you
352353
"ip_type": "IPv4",
353354
"interval": 300
354355
}
355-
356356
```
357357

358358
</details>
@@ -596,12 +596,14 @@ For Scaleway, you need to provide an API Secret Key as the `login_token` ([How t
596596
{
597597
"provider": "Scaleway",
598598
"login_token": "API Secret Key",
599-
"domains": [{
599+
"domains": [
600+
{
600601
"domain_name": "example.com",
601-
"sub_domains": ["www","@"]
602-
},{
602+
"sub_domains": ["www", "@"]
603+
},
604+
{
603605
"domain_name": "samplednszone.example.com",
604-
"sub_domains": ["www","test"]
606+
"sub_domains": ["www", "test"]
605607
}
606608
],
607609
"resolver": "8.8.8.8",
@@ -825,9 +827,7 @@ For Dynu, you need to configure the `password`, config 1 default domain & subdom
825827
"domains": [
826828
{
827829
"domain_name": "your_domain.com",
828-
"sub_domains": [
829-
"your_subdomain"
830-
]
830+
"sub_domains": ["your_subdomain"]
831831
}
832832
],
833833
"resolver": "8.8.8.8",
@@ -995,6 +995,28 @@ The `message_template` property supports [html](https://pushover.net/api#html) i
995995
If the `device` and `title` parameters are left empty, Pushover will choose defaults [see](https://pushover.net/api#messages). More details on the priority parameter
996996
can be found on the Pushover [API description](https://pushover.net/api#priority).
997997

998+
#### Bark
999+
1000+
To receive a [Bark](https://bark.day.app/) message each time the IP changes, update your configuration with the following snippet:
1001+
1002+
```json
1003+
"notify": {
1004+
"bark": {
1005+
"enabled": true,
1006+
"server": "https://api.day.app",
1007+
"device_keys": "",
1008+
"params": "{ \"isArchive\": 1, \"action\": \"none\" }"
1009+
}
1010+
}
1011+
```
1012+
1013+
`server` Bark server address. You can use the default official server `https://api.day.app` or set it to a self-hosted server address.
1014+
`device_keys` device key, supports multiple keys (comma-separated) for batch push.
1015+
`params` Bark request parameters, please refer to [Bark API](https://bark.day.app/#/en-us/tutorial?id=request-parameters)
1016+
`user` Basic auth username of the self-hosted server, same with server side environment variable `BARK_SERVER_BASIC_AUTH_USER`.
1017+
`password` Basic auth password of the self-hosted server, same with server side environment variable `BARK_SERVER_BASIC_AUTH_PASSWORD`.
1018+
For more information, please refer to the [Bark official documentation](https://bark.day.app/)
1019+
9981020
### Webhook
9991021

10001022
Webhook is another feature that GoDNS provides to deliver notifications to other applications while the IP is changed. GoDNS delivers a notification to the target URL via an HTTP `GET` or `POST` request.
@@ -1161,6 +1183,7 @@ Starting from version 3.1.0, GoDNS provides a web panel to manage the configurat
11611183
```
11621184

11631185
After enabling the web panel, you can visit `http://localhost:9000` to manage the configuration and monitor the status of the domains.
1186+
11641187
## Running GoDNS
11651188

11661189
There are a few ways to run GoDNS.
@@ -1216,6 +1239,7 @@ Note: when the program stops, it will not be restarted.
12161239
### As a managed daemon (with procd)
12171240

12181241
`procd` is the init system on OpenWRT. If you want to use godns as a service with OpenWRT and procd:
1242+
12191243
1. Copy `./config/procd/godns` to `/etc/init.d` (and tweak it to your needs)
12201244
2. Start the service (with root privilege):
12211245

@@ -1282,8 +1306,9 @@ Contributions are welcome! Please feel free to submit a Pull Request.
12821306
### Setup the frontend development environment
12831307

12841308
Requirements:
1285-
* Node.js `18.19.0` or higher
1286-
* Go `1.17` or higher
1309+
1310+
- Node.js `18.19.0` or higher
1311+
- Go `1.17` or higher
12871312

12881313
The frontend project is built with [Next.js](https://nextjs.org/) and [daisyUI](https://daisyui.com/). To start the development environment, run:
12891314

@@ -1292,6 +1317,7 @@ cd web
12921317
npm ci
12931318
npm run dev
12941319
```
1320+
12951321
### Build the frontend
12961322

12971323
To build the frontend, run:

README_CN.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
╚██████╔╝╚██████╔╝██████╔╝██║ ╚████║███████║
77
╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
88
```
9-
9+
1010
[![Apache licensed][9]][10] [![Docker][3]][4] [![Go Report Card][11]][12] [![GoDoc][13]][14]
1111

1212
[3]: https://img.shields.io/docker/image-size/timothyye/godns/latest
@@ -60,6 +60,7 @@
6060
- [Slack](#slack)
6161
- [Discord](#discord)
6262
- [Pushover](#pushover)
63+
- [Bark](#bark)
6364
- [Webhook](#webhook)
6465
- [使用 HTTP GET 请求的 Webhook](#使用-http-get-请求的-webhook)
6566
- [使用 HTTP POST 请求的 Webhook](#使用-http-post-请求的-webhook)
@@ -90,7 +91,7 @@
9091

9192
## 支持的 DNS 提供商
9293

93-
| 提供商 | IPv4 支持 | IPv6 支持 | 根域名 | 子域名 |
94+
| 提供商 | IPv4 支持 | IPv6 支持 | 根域名 | 子域名 |
9495
| ------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: |
9596
| [Cloudflare][cloudflare] | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
9697
| [DigitalOcean][digitalocean] | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
@@ -110,7 +111,7 @@
110111
| [Hetzner][hetzner] | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
111112
| [OVH][ovh] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
112113
| [Dynu][dynu] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
113-
| [IONOS][ionos] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
114+
| [IONOS][ionos] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
114115
| [TransIP][transip] | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
115116

116117
[cloudflare]: https://cloudflare.com
@@ -350,7 +351,6 @@ GoDNS 支持动态加载配置。如果您修改了配置文件,GoDNS 将自
350351
"ip_type": "IPv4",
351352
"interval": 300
352353
}
353-
354354
```
355355

356356
</details>
@@ -594,12 +594,14 @@ GoDNS 支持动态加载配置。如果您修改了配置文件,GoDNS 将自
594594
{
595595
"provider": "Scaleway",
596596
"login_token": "API Secret Key",
597-
"domains": [{
597+
"domains": [
598+
{
598599
"domain_name": "example.com",
599-
"sub_domains": ["www","@"]
600-
},{
600+
"sub_domains": ["www", "@"]
601+
},
602+
{
601603
"domain_name": "samplednszone.example.com",
602-
"sub_domains": ["www","test"]
604+
"sub_domains": ["www", "test"]
603605
}
604606
],
605607
"resolver": "8.8.8.8",
@@ -777,7 +779,7 @@ GoDNS Linode 处理程序目前对 Linode DNS 记录使用固定的 30 秒 TTL
777779

778780
对于 OVH,您需要提供 Consumerkey、Appsecret 和 Appkey,并配置所有域名和子域名。
779781
所需的值可以通过访问[此网站](https://www.ovh.com/auth/api/createToken)获取
780-
权限应在 GET、POST 和 PUT 上设置为 '*'
782+
权限应在 GET、POST 和 PUT 上设置为 '\*'
781783
更多信息:[help.ovhcloud.com](https://help.ovhcloud.com/csm/en-gb-api-getting-started-ovhcloud-api?id=kb_article_view&sysparm_article=KB0042784)
782784

783785
<details>
@@ -823,9 +825,7 @@ GoDNS Linode 处理程序目前对 Linode DNS 记录使用固定的 30 秒 TTL
823825
"domains": [
824826
{
825827
"domain_name": "your_domain.com",
826-
"sub_domains": [
827-
"your_subdomain"
828-
]
828+
"sub_domains": ["your_subdomain"]
829829
}
830830
],
831831
"resolver": "8.8.8.8",
@@ -993,6 +993,28 @@ GoDNS 可以在 IP 更改时发送通知。
993993
如果 `device` 和 `title` 参数留空,Pushover 将选择默认值[参见](https://pushover.net/api#messages)。有关优先级参数的更多详细信息
994994
可以在 Pushover [API 描述](https://pushover.net/api#priority) 中找到。
995995

996+
#### Bark
997+
998+
要在 IP 更改时接收 [Bark](https://bark.day.app/) 消息,使用以下片段更新您的配置:
999+
1000+
```json
1001+
"notify": {
1002+
"bark": {
1003+
"enabled": true,
1004+
"server": "https://api.day.app",
1005+
"device_keys": "",
1006+
"params": "{ \"isArchive\": 1, \"action\": \"none\" }"
1007+
}
1008+
}
1009+
```
1010+
1011+
`server` Bark 服务器地址,可使用官方默认服务器 `https://api.day.app`,也可设置为自建服务器地址。
1012+
`device_keys` 设备 key,支持多个(英文逗号分隔),多个时,用于批量推送。
1013+
`params` Bark 请求参数,可参考 [Bark API](https://bark.day.app/#/tutorial?id=%e8%af%b7%e6%b1%82%e5%8f%82%e6%95%b0)
1014+
`user` 自建服务器 Basic auth 用户名,与服务端环境变量 `BARK_SERVER_BASIC_AUTH_USER` 一致。
1015+
`password` 自建服务器 Basic auth 密码,与服务端环境变量 `BARK_SERVER_BASIC_AUTH_PASSWORD` 一致。
1016+
更多内容请参阅 [Bark 官方文档](https://bark.day.app/)
1017+
9961018
### Webhook
9971019

9981020
Webhook 是 GoDNS 提供的另一个功能,用于在 IP 更改时向其他应用程序发送通知。GoDNS 通过 HTTP `GET` 或 `POST` 请求向目标 URL 发送通知。

configs/config_sample.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@
55
"domains": [
66
{
77
"domain_name": "example.com",
8-
"sub_domains": [
9-
"www",
10-
"test"
11-
]
8+
"sub_domains": ["www", "test"]
129
},
1310
{
1411
"domain_name": "example2.com",
15-
"sub_domains": [
16-
"www",
17-
"test"
18-
]
12+
"sub_domains": ["www", "test"]
1913
}
2014
],
2115
"ip_urls": [
@@ -70,6 +64,14 @@
7064
"smtp_port": 25,
7165
"send_from": "",
7266
"send_to": ""
67+
},
68+
"bark": {
69+
"enabled": false,
70+
"server": "https://api.day.app",
71+
"device_keys": "",
72+
"params": "{ \"isArchive\": 1, \"action\": \"none\" }",
73+
"user": "",
74+
"password": ""
7375
}
7476
},
7577
"webhook": {

configs/config_sample.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@ domains:
66
sub_domains:
77
- www
88
- test
9-
ip_urls: [https://api4.ipify.org, https://api-ipv4.ip.sb/ip, https://ip2location.io/ip, "https://ipinfo.io/ip"]
10-
ipv6_urls: [https://api6.ipify.org, https://api-ipv6.ip.sb/ip, https://ip2location.io/ip, "https://v6.ipinfo.io/ip"]
9+
ip_urls:
10+
[
11+
https://api4.ipify.org,
12+
https://api-ipv4.ip.sb/ip,
13+
https://ip2location.io/ip,
14+
"https://ipinfo.io/ip",
15+
]
16+
ipv6_urls:
17+
[
18+
https://api6.ipify.org,
19+
https://api-ipv6.ip.sb/ip,
20+
https://ip2location.io/ip,
21+
"https://v6.ipinfo.io/ip",
22+
]
1123
ip_type: IPv4
1224
interval: 300
1325
resolver: 8.8.8.8
@@ -42,7 +54,14 @@ notify:
4254
smtp_port: 25
4355
send_from:
4456
send_to:
57+
bark:
58+
enabled: false
59+
server: "https://api.day.app"
60+
device_keys: ""
61+
params: '{ "isArchive": 1, "action": "none" }'
62+
user: ""
63+
password: ""
4564
webhook:
4665
enabled: false
4766
url: "http://localhost:5000/api/v1/send"
48-
request_body: "{ \"domain\": \"{{.Domain}}\", \"ip\": \"{{.CurrentIP}}\", \"ip_type\": \"{{.IPType}}\" }"
67+
request_body: '{ "domain": "{{.Domain}}", "ip": "{{.CurrentIP}}", "ip_type": "{{.IPType}}" }'

internal/settings/settings.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,26 @@ type PushoverNotify struct {
7777
HTML int `json:"html" yaml:"html"`
7878
}
7979

80+
type BarkNotify struct {
81+
Enabled bool `json:"enabled" yaml:"enabled"`
82+
Server string `json:"server" yaml:"server"`
83+
Title string `json:"title" yaml:"title"`
84+
Subtitle string `json:"subtitle" yaml:"subtitle"`
85+
Body string `json:"body" yaml:"body"`
86+
DeviceKeys string `json:"device_keys" yaml:"device_keys"`
87+
Params string `json:"params" yaml:"params"`
88+
User string `json:"user" yaml:"user"`
89+
Password string `json:"password" yaml:"password"`
90+
}
91+
8092
// Notify struct.
8193
type Notify struct {
8294
Telegram TelegramNotify `json:"telegram" yaml:"telegram"`
8395
Mail MailNotify `json:"mail" yaml:"mail"`
8496
Slack SlackNotify `json:"slack" yaml:"slack"`
8597
Discord DiscordNotify `json:"discord" yaml:"discord"`
8698
Pushover PushoverNotify `json:"pushover" yaml:"pushover"`
99+
Bark BarkNotify `json:"bark" yaml:"bark"`
87100
}
88101

89102
// Webhook struct.

0 commit comments

Comments
 (0)