ddns 3.1.6__tar.gz → 4.0.0b3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ddns might be problematic. Click here for more details.
- ddns-4.0.0b3/PKG-INFO +301 -0
- ddns-4.0.0b3/README.md +260 -0
- ddns-4.0.0b3/ddns.egg-info/PKG-INFO +301 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/alidns.py +4 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/callback.py +4 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/cloudflare.py +4 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/dnscom.py +4 -7
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/dnspod.py +5 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/he.py +4 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/huaweidns.py +5 -6
- {ddns-3.1.6 → ddns-4.0.0b3}/run.py +28 -28
- {ddns-3.1.6 → ddns-4.0.0b3}/setup.py +2 -2
- {ddns-3.1.6 → ddns-4.0.0b3}/util/cache.py +3 -4
- ddns-4.0.0b3/util/config.py +193 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/util/ip.py +3 -5
- ddns-3.1.6/PKG-INFO +0 -288
- ddns-3.1.6/README.md +0 -247
- ddns-3.1.6/ddns.egg-info/PKG-INFO +0 -288
- ddns-3.1.6/util/config.py +0 -126
- {ddns-3.1.6 → ddns-4.0.0b3}/LICENSE +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/ddns.egg-info/SOURCES.txt +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/ddns.egg-info/dependency_links.txt +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/ddns.egg-info/entry_points.txt +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/ddns.egg-info/top_level.txt +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/__init__.py +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/dns/dnspod_com.py +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/setup.cfg +0 -0
- {ddns-3.1.6 → ddns-4.0.0b3}/util/__init__.py +0 -0
ddns-4.0.0b3/PKG-INFO
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ddns
|
|
3
|
+
Version: 4.0.0b3
|
|
4
|
+
Summary: automatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]
|
|
5
|
+
Home-page: https://ddns.newfuture.cc
|
|
6
|
+
Author: NewFuture
|
|
7
|
+
Author-email: python@newfuture.cc
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Bug Reports, https://github.com/NewFuture/DDNS/issues
|
|
10
|
+
Project-URL: Source, https://github.com/NewFuture/DDNS
|
|
11
|
+
Keywords: ddns ipv6 ipv4 dns dnspod alidns cloudflare
|
|
12
|
+
Platform: any
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: Intended Audience :: Information Technology
|
|
17
|
+
Classifier: Intended Audience :: System Administrators
|
|
18
|
+
Classifier: Topic :: Internet
|
|
19
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
20
|
+
Classifier: Topic :: System :: Networking
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
23
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
24
|
+
Classifier: Programming Language :: Python :: 3
|
|
25
|
+
Requires-Python: >=2.5, <4
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Dynamic: author
|
|
29
|
+
Dynamic: author-email
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: platform
|
|
38
|
+
Dynamic: project-url
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
# [<img src="doc/img/ddns.svg" width="32px" height="32px"/>](https://ddns.newfuture.cc) [DDNS](https://github.com/NewFuture/DDNS)
|
|
43
|
+
|
|
44
|
+
> 自动更新 DNS 解析 到本机 IP 地址,支持 IPv4 和 IPv6,本地(内网)IP 和公网 IP。
|
|
45
|
+
> 代理模式,支持自动创建 DNS 记录。
|
|
46
|
+
|
|
47
|
+
[](https://github.com/NewFuture/DDNS/releases/latest)
|
|
49
|
+
[](https://pypi.org/project/ddns/)
|
|
50
|
+
[](https://hub.docker.com/r/newfuture/ddns)
|
|
51
|
+
[](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)
|
|
52
|
+
[](https://github.com/NewFuture/DDNS/actions/workflows/publish.yml)
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- 兼容和跨平台:
|
|
59
|
+
- [Docker (@NN708)](https://hub.docker.com/r/newfuture/ddns) [](https://hub.docker.com/r/newfuture/ddns)[](https://hub.docker.com/r/newfuture/ddns)
|
|
60
|
+
- [PIP 安装 (兼容Python2)](https://pypi.org/project/ddns/)  
|
|
61
|
+
- [二进制文件](https://github.com/NewFuture/DDNS/releases/latest) 
|
|
62
|
+
|
|
63
|
+
- 域名支持:
|
|
64
|
+
- 多个域名支持
|
|
65
|
+
- 多级域名解析
|
|
66
|
+
- 自动创建新 DNS 记录
|
|
67
|
+
- IP 类型:
|
|
68
|
+
- 内网 IPv4 / IPv6
|
|
69
|
+
- 公网 IPv4 / IPv6 (支持自定义 API)
|
|
70
|
+
- 自定义命令(shell)
|
|
71
|
+
- 正则选取支持 (@rufengsuixing)
|
|
72
|
+
- 网络代理:
|
|
73
|
+
- http 代理支持
|
|
74
|
+
- 多代理自动切换
|
|
75
|
+
- 服务商支持:
|
|
76
|
+
- [DNSPOD](https://www.dnspod.cn/)
|
|
77
|
+
- [阿里 DNS](http://www.alidns.com/)
|
|
78
|
+
- [DNS.COM](https://www.dns.com/) (@loftor-git)
|
|
79
|
+
- [DNSPOD 国际版](https://www.dnspod.com/)
|
|
80
|
+
- [CloudFlare](https://www.cloudflare.com/) (@tongyifan)
|
|
81
|
+
- [HE.net](https://dns.he.net/) (@NN708) (不支持自动创建记录)
|
|
82
|
+
- [华为云](https://huaweicloud.com/) (@cybmp3)
|
|
83
|
+
- 其他:
|
|
84
|
+
- 可设置定时任务
|
|
85
|
+
- TTL 配置支持
|
|
86
|
+
- 本地文件缓存(减少 API 请求)
|
|
87
|
+
- 地址变更时触发自定义回调 API(与 DDNS 功能互斥)
|
|
88
|
+
|
|
89
|
+
## 使用
|
|
90
|
+
|
|
91
|
+
### ① 安装
|
|
92
|
+
|
|
93
|
+
根据需要选择一种方式:`二进制`版、`pip`版、`源码`运行,或者 `Docker`。
|
|
94
|
+
|
|
95
|
+
推荐 Docker 版,兼容性最佳,体积小,性能优化。
|
|
96
|
+
|
|
97
|
+
- #### pip 安装(需要 pip 或 easy_install)
|
|
98
|
+
|
|
99
|
+
1. 安装 ddns: `pip install ddns` 或 `easy_install ddns`
|
|
100
|
+
2. 运行: `ddns`
|
|
101
|
+
|
|
102
|
+
- #### 二进制版(单文件,无需 python)
|
|
103
|
+
|
|
104
|
+
- Windows [ddns.exe](https://github.com/NewFuture/DDNS/releases/latest)
|
|
105
|
+
- Linux(仅 Ubuntu 测试) [ddns](https://github.com/NewFuture/DDNS/releases/latest)
|
|
106
|
+
- Mac OSX [ddns-mac](https://github.com/NewFuture/DDNS/releases/latest)
|
|
107
|
+
|
|
108
|
+
- #### 源码运行(无任何依赖,需 python 环境)
|
|
109
|
+
|
|
110
|
+
1. clone 或者 [下载此仓库](https://github.com/NewFuture/DDNS/archive/master.zip) 并解压
|
|
111
|
+
2. 运行 ./run.py(windows 双击 `run.bat` 或者运行 `python run.py`)
|
|
112
|
+
|
|
113
|
+
- #### Docker(需要安装 Docker)
|
|
114
|
+
|
|
115
|
+
- 使用环境变量:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
docker run -d \
|
|
119
|
+
-e DDNS_DNS=dnspod \
|
|
120
|
+
-e DDNS_ID=12345 \
|
|
121
|
+
-e DDNS_TOKEN=mytokenkey \
|
|
122
|
+
-e DDNS_IPV4=ddns.newfuture.cc \
|
|
123
|
+
-e DDNS_IPV6=ddns.newfuture.cc \
|
|
124
|
+
--network host \
|
|
125
|
+
newfuture/ddns
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- 使用配置文件(docker 工作目录 `/ddns/`,默认配置位置 `/ddns/config.json`):
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
docker run -d \
|
|
132
|
+
-v /local/config/path/:/ddns/ \
|
|
133
|
+
--network host \
|
|
134
|
+
newfuture/ddns
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### ② 快速配置
|
|
138
|
+
|
|
139
|
+
1. 申请 api `token`,填写到对应的 `id` 和 `token` 字段:
|
|
140
|
+
|
|
141
|
+
- [DNSPOD(国内版)创建 token](https://support.dnspod.cn/Kb/showarticle/tsid/227/)
|
|
142
|
+
- [阿里云 accesskey](https://help.aliyun.com/document_detail/87745.htm)
|
|
143
|
+
- [DNS.COM API Key/Secret](https://www.dns.com/member/apiSet)
|
|
144
|
+
- [DNSPOD(国际版)](https://www.dnspod.com/docs/info.html#get-the-user-token)
|
|
145
|
+
- [CloudFlare API Key](https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key-)(除了 `email + API KEY`,也可使用 `Token`,需要列出 Zone 权限)
|
|
146
|
+
- [HE.net DDNS 文档](https://dns.he.net/docs.html)(仅需将设置的密码填入 `token` 字段,`id` 字段可留空)
|
|
147
|
+
- [华为 APIKEY 申请](https://console.huaweicloud.com/iam/)(点左边访问密钥,然后点新增访问密钥)
|
|
148
|
+
- 自定义回调的参数填写方式请查看下方的自定义回调配置说明
|
|
149
|
+
|
|
150
|
+
2. 修改配置文件,`ipv4` 和 `ipv6` 字段,为待更新的域名,详细参照配置说明
|
|
151
|
+
|
|
152
|
+
## 详细配置
|
|
153
|
+
|
|
154
|
+
所有字段可通过三种方式进行配置
|
|
155
|
+
|
|
156
|
+
1. 命令行参数 `ddns --key=value`(`ddns -h` 查看详情),优先级最高
|
|
157
|
+
2. JSON 配置文件(值为 null 认为是有效值,会覆盖环境变量的设置,如果没有对应的 key 则会尝试使用环境变量)
|
|
158
|
+
3. 环境变量 DDNS_ 前缀加上 key 全大写或者全小写,点转下划线(`${ddns_id}` 或 `${DDNS_ID}`,`${DDNS_LOG_LEVEL}`)
|
|
159
|
+
|
|
160
|
+
<details open>
|
|
161
|
+
<summary markdown="span">config.json 配置文件</summary>
|
|
162
|
+
|
|
163
|
+
- 首次运行会自动生成一个模板配置文件
|
|
164
|
+
- 可以使用 `-c` 使用指定的配置文件(默认读取当前目录的 config.json)
|
|
165
|
+
- 推荐使用 vscode 等支持 JsonSchema 的编辑器编辑配置文件
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
ddns -c path/to/config.json
|
|
169
|
+
# 或者源码运行
|
|
170
|
+
python run.py -c /path/to/config.json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### 配置参数表
|
|
174
|
+
|
|
175
|
+
| key | type | required | default | description | tips |
|
|
176
|
+
| :------: | :----------------: | :------: | :---------: | :---------------: | ----------------------------------------------------------------------------------------------------------- |
|
|
177
|
+
| id | string | √ | 无 | api 访问 ID | Cloudflare 为邮箱(使用 Token 时留空)<br>HE.net 可留空<br>华为云为 Access Key ID (AK) |
|
|
178
|
+
| token | string | √ | 无 | api 授权 token | 部分平台叫 secret key,**反馈粘贴时删除** |
|
|
179
|
+
| dns | string | No | `"dnspod"` | dns 服务商 | 阿里 DNS 为 `alidns`,Cloudflare 为 `cloudflare`,dns.com 为 `dnscom`,DNSPOD 国内为 `dnspod`,DNSPOD 国际为 `dnspod_com`,HE.net 为 `he`,华为云为 `huaweidns`,自定义回调为 `callback` |
|
|
180
|
+
| ipv4 | array | No | `[]` | ipv4 域名列表 | 为 `[]` 时,不会获取和更新 IPv4 地址 |
|
|
181
|
+
| ipv6 | array | No | `[]` | ipv6 域名列表 | 为 `[]` 时,不会获取和更新 IPv6 地址 |
|
|
182
|
+
| index4 | string\|int\|array | No | `"default"` | ipv4 获取方式 | 可设置 `网卡`、`内网`、`公网`、`正则` 等方式 |
|
|
183
|
+
| index6 | string\|int\|array | No | `"default"` | ipv6 获取方式 | 可设置 `网卡`、`内网`、`公网`、`正则` 等方式 |
|
|
184
|
+
| ttl | number | No | `null` | DNS 解析 TTL 时间 | 不设置采用 DNS 默认策略 |
|
|
185
|
+
| proxy | string\|array | No | 无 | http 代理 `;` 分割 | 多代理逐个尝试直到成功,`DIRECT` 为直连 |
|
|
186
|
+
| ~~debug~~| bool | No | `false` | 是否开启调试 | v4 中弃用,请改用 log.level=DEBUG |
|
|
187
|
+
| cache | string\|bool | No | `true` | 是否缓存记录 | 正常情况打开避免频繁更新,默认位置为临时目录下 `ddns.cache`,也可以指定一个具体路径 |
|
|
188
|
+
| log | {"level":string,"file":string} | No | `null` | 日志配置(可选) | 日志配置,日志级别和路径(默认命令行),例如:`{ "level": "DEBUG", "file": "dns.log" }` |
|
|
189
|
+
|
|
190
|
+
#### index4 和 index6 参数说明
|
|
191
|
+
|
|
192
|
+
- 数字(`0`,`1`,`2`,`3`等):第 i 个网卡 ip
|
|
193
|
+
- 字符串 `"default"`(或者无此项):系统访问外网默认 IP
|
|
194
|
+
- 字符串 `"public"`:使用公网 ip(使用公网 API 查询,url 的简化模式)
|
|
195
|
+
- 字符串 `"url:xxx"`:打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
|
|
196
|
+
- 字符串 `"regex:xxx"` 正则表达(如 `"regex:192.*"`):提取 `ifconfig`/`ipconfig` 中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
|
|
197
|
+
- `"192.*"` 表示 192 开头的所有 ip(注意 `regex:` 不可省略)
|
|
198
|
+
- 如果想匹配 `10.00.xxxx` 应该写成 `"regex:10\\.00\\..*"`(`"\\"` json 转义成 `\`)
|
|
199
|
+
- 字符串 `"cmd:xxxx"`:执行命令 `xxxx` 的 stdout 输出结果作为目标 IP
|
|
200
|
+
- 字符串 `"shell:xxx"`:使用系统 shell 运行 `xxx`,并把结果 stdout 作为目标 IP
|
|
201
|
+
- `false`:强制禁止更新 ipv4 或 ipv6 的 DNS 解析
|
|
202
|
+
- 列表:依次执行列表中的 index 规则,并将最先获得的结果作为目标 IP
|
|
203
|
+
- 例如 `["public", "regex:172\\..*"]` 将先查询公网 API,未获取到 IP 后再从本地寻找 172 开头的 IP
|
|
204
|
+
|
|
205
|
+
#### 自定义回调配置说明
|
|
206
|
+
|
|
207
|
+
- `id` 字段填写回调地址,以 HTTP 或 HTTPS 开头,推荐采用 HTTPS 方式的回调 API ,当 `token` 字段非空且 URL 参数包含下表所示的常量字符串时,会自动替换为实际内容。
|
|
208
|
+
- `token` 字段为 POST 参数,本字段为空或不存在则使用 GET 方式发起回调,回调参数采用 JSON 格式编码,当 JSON 的首层参数值包含下表所示的常量字符串时,会自动替换为实际内容。
|
|
209
|
+
|
|
210
|
+
| 常量名称 | 常量内容 | 说明 |
|
|
211
|
+
| ---------------- | ---------------------- | -------- |
|
|
212
|
+
| `__DOMAIN__` | DDNS 域名 | |
|
|
213
|
+
| `__RECORDTYPE__` | DDNS 记录类型 | |
|
|
214
|
+
| `__TTL__` | DDNS TTL | |
|
|
215
|
+
| `__TIMESTAMP__` | 请求发起时间戳 | 包含小数 |
|
|
216
|
+
| `__IP__` | 获取的对应类型的 IP 地址 | |
|
|
217
|
+
|
|
218
|
+
#### 配置示例
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
|
|
223
|
+
"id": "12345",
|
|
224
|
+
"token": "mytokenkey",
|
|
225
|
+
"dns": "dnspod 或 dnspod_com 或 alidns 或 dnscom 或 cloudflare 或 he 或 huaweidns 或 callback",
|
|
226
|
+
"ipv4": ["ddns.newfuture.cc", "ipv4.ddns.newfuture.cc"],
|
|
227
|
+
"ipv6": ["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"],
|
|
228
|
+
"index4": 0,
|
|
229
|
+
"index6": "public",
|
|
230
|
+
"ttl": 600,
|
|
231
|
+
"proxy": "127.0.0.1:1080;DIRECT",
|
|
232
|
+
"log": {
|
|
233
|
+
"level": "DEBUG",
|
|
234
|
+
"file": "dns.log"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
</details>
|
|
239
|
+
|
|
240
|
+
## 定时任务
|
|
241
|
+
|
|
242
|
+
<details>
|
|
243
|
+
<summary markdown="span">可以通过脚本设置定时任务(默认每 5 分钟检查一次 IP,自动更新)</summary>
|
|
244
|
+
|
|
245
|
+
#### Windows
|
|
246
|
+
|
|
247
|
+
- [推荐] 以系统身份运行,右键“以管理员身份运行”`task.bat`(或者在管理员命令行中运行)
|
|
248
|
+
- 以当前用户身份运行定时任务,双击或运行 `task.bat`(执行时会闪黑框)
|
|
249
|
+
|
|
250
|
+
#### Linux
|
|
251
|
+
|
|
252
|
+
- 使用 init.d 和 crontab:
|
|
253
|
+
```bash
|
|
254
|
+
sudo ./task.sh
|
|
255
|
+
```
|
|
256
|
+
- 使用 systemd:
|
|
257
|
+
```bash
|
|
258
|
+
安装:
|
|
259
|
+
sudo ./systemd.sh install
|
|
260
|
+
卸载:
|
|
261
|
+
sudo ./systemd.sh uninstall
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
该脚本安装的文件符合 [Filesystem Hierarchy Standard (FHS)](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard):
|
|
265
|
+
可执行文件所在目录为 `/usr/share/DDNS`
|
|
266
|
+
配置文件所在目录为 `/etc/DDNS`
|
|
267
|
+
|
|
268
|
+
#### Docker
|
|
269
|
+
|
|
270
|
+
Docker 镜像在无额外参数的情况下,已默认启用每 5 分钟执行一次的定时任务
|
|
271
|
+
|
|
272
|
+
</details>
|
|
273
|
+
|
|
274
|
+
## FAQ
|
|
275
|
+
|
|
276
|
+
<details>
|
|
277
|
+
<summary markdown="span">Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]</summary>
|
|
278
|
+
|
|
279
|
+
> Windows Server 默认安全策略会禁止任何未添加的信任 SSL 证书,可手动添加一下对应的证书 [#56](https://github.com/NewFuture/DDNS/issues/56#issuecomment-487371078)
|
|
280
|
+
|
|
281
|
+
使用系统自带的 IE 浏览器访问一次对应的 API 即可
|
|
282
|
+
|
|
283
|
+
- alidns 打开: <https://alidns.aliyuncs.com>
|
|
284
|
+
- cloudflare 打开: <https://api.cloudflare.com>
|
|
285
|
+
- dns.com 打开: <https://www.dns.com>
|
|
286
|
+
- dnspod.cn 打开: <https://dnsapi.cn>
|
|
287
|
+
- dnspod 国际版: <https://api.dnspod.com>
|
|
288
|
+
- 华为 DNS <https://dns.myhuaweicloud.com>
|
|
289
|
+
</details>
|
|
290
|
+
|
|
291
|
+
<details>
|
|
292
|
+
<summary markdown="span">问题排查反馈</summary>
|
|
293
|
+
|
|
294
|
+
1. 先确认排查是否是系统/网络环境问题
|
|
295
|
+
2. 在 [issues](https://github.com/NewFuture/DDNS/issues) 中搜索是否有类似问题
|
|
296
|
+
3. 前两者均无法解决或者确定是 bug,[在此新建 issue](https://github.com/NewFuture/DDNS/issues/new)
|
|
297
|
+
- [ ] 开启 debug 配置
|
|
298
|
+
- [ ] 附上这些内容 **运行版本和方式**、**系统环境**、**出错日志**、**去掉 id/token** 的配置文件
|
|
299
|
+
- [ ] 源码运行注明使用的 python 环境
|
|
300
|
+
|
|
301
|
+
</details>
|
ddns-4.0.0b3/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# [<img src="doc/img/ddns.svg" width="32px" height="32px"/>](https://ddns.newfuture.cc) [DDNS](https://github.com/NewFuture/DDNS)
|
|
2
|
+
|
|
3
|
+
> 自动更新 DNS 解析 到本机 IP 地址,支持 IPv4 和 IPv6,本地(内网)IP 和公网 IP。
|
|
4
|
+
> 代理模式,支持自动创建 DNS 记录。
|
|
5
|
+
|
|
6
|
+
[](https://github.com/NewFuture/DDNS/releases/latest)
|
|
8
|
+
[](https://pypi.org/project/ddns/)
|
|
9
|
+
[](https://hub.docker.com/r/newfuture/ddns)
|
|
10
|
+
[](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)
|
|
11
|
+
[](https://github.com/NewFuture/DDNS/actions/workflows/publish.yml)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 兼容和跨平台:
|
|
18
|
+
- [Docker (@NN708)](https://hub.docker.com/r/newfuture/ddns) [](https://hub.docker.com/r/newfuture/ddns)[](https://hub.docker.com/r/newfuture/ddns)
|
|
19
|
+
- [PIP 安装 (兼容Python2)](https://pypi.org/project/ddns/)  
|
|
20
|
+
- [二进制文件](https://github.com/NewFuture/DDNS/releases/latest) 
|
|
21
|
+
|
|
22
|
+
- 域名支持:
|
|
23
|
+
- 多个域名支持
|
|
24
|
+
- 多级域名解析
|
|
25
|
+
- 自动创建新 DNS 记录
|
|
26
|
+
- IP 类型:
|
|
27
|
+
- 内网 IPv4 / IPv6
|
|
28
|
+
- 公网 IPv4 / IPv6 (支持自定义 API)
|
|
29
|
+
- 自定义命令(shell)
|
|
30
|
+
- 正则选取支持 (@rufengsuixing)
|
|
31
|
+
- 网络代理:
|
|
32
|
+
- http 代理支持
|
|
33
|
+
- 多代理自动切换
|
|
34
|
+
- 服务商支持:
|
|
35
|
+
- [DNSPOD](https://www.dnspod.cn/)
|
|
36
|
+
- [阿里 DNS](http://www.alidns.com/)
|
|
37
|
+
- [DNS.COM](https://www.dns.com/) (@loftor-git)
|
|
38
|
+
- [DNSPOD 国际版](https://www.dnspod.com/)
|
|
39
|
+
- [CloudFlare](https://www.cloudflare.com/) (@tongyifan)
|
|
40
|
+
- [HE.net](https://dns.he.net/) (@NN708) (不支持自动创建记录)
|
|
41
|
+
- [华为云](https://huaweicloud.com/) (@cybmp3)
|
|
42
|
+
- 其他:
|
|
43
|
+
- 可设置定时任务
|
|
44
|
+
- TTL 配置支持
|
|
45
|
+
- 本地文件缓存(减少 API 请求)
|
|
46
|
+
- 地址变更时触发自定义回调 API(与 DDNS 功能互斥)
|
|
47
|
+
|
|
48
|
+
## 使用
|
|
49
|
+
|
|
50
|
+
### ① 安装
|
|
51
|
+
|
|
52
|
+
根据需要选择一种方式:`二进制`版、`pip`版、`源码`运行,或者 `Docker`。
|
|
53
|
+
|
|
54
|
+
推荐 Docker 版,兼容性最佳,体积小,性能优化。
|
|
55
|
+
|
|
56
|
+
- #### pip 安装(需要 pip 或 easy_install)
|
|
57
|
+
|
|
58
|
+
1. 安装 ddns: `pip install ddns` 或 `easy_install ddns`
|
|
59
|
+
2. 运行: `ddns`
|
|
60
|
+
|
|
61
|
+
- #### 二进制版(单文件,无需 python)
|
|
62
|
+
|
|
63
|
+
- Windows [ddns.exe](https://github.com/NewFuture/DDNS/releases/latest)
|
|
64
|
+
- Linux(仅 Ubuntu 测试) [ddns](https://github.com/NewFuture/DDNS/releases/latest)
|
|
65
|
+
- Mac OSX [ddns-mac](https://github.com/NewFuture/DDNS/releases/latest)
|
|
66
|
+
|
|
67
|
+
- #### 源码运行(无任何依赖,需 python 环境)
|
|
68
|
+
|
|
69
|
+
1. clone 或者 [下载此仓库](https://github.com/NewFuture/DDNS/archive/master.zip) 并解压
|
|
70
|
+
2. 运行 ./run.py(windows 双击 `run.bat` 或者运行 `python run.py`)
|
|
71
|
+
|
|
72
|
+
- #### Docker(需要安装 Docker)
|
|
73
|
+
|
|
74
|
+
- 使用环境变量:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
docker run -d \
|
|
78
|
+
-e DDNS_DNS=dnspod \
|
|
79
|
+
-e DDNS_ID=12345 \
|
|
80
|
+
-e DDNS_TOKEN=mytokenkey \
|
|
81
|
+
-e DDNS_IPV4=ddns.newfuture.cc \
|
|
82
|
+
-e DDNS_IPV6=ddns.newfuture.cc \
|
|
83
|
+
--network host \
|
|
84
|
+
newfuture/ddns
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- 使用配置文件(docker 工作目录 `/ddns/`,默认配置位置 `/ddns/config.json`):
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
docker run -d \
|
|
91
|
+
-v /local/config/path/:/ddns/ \
|
|
92
|
+
--network host \
|
|
93
|
+
newfuture/ddns
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### ② 快速配置
|
|
97
|
+
|
|
98
|
+
1. 申请 api `token`,填写到对应的 `id` 和 `token` 字段:
|
|
99
|
+
|
|
100
|
+
- [DNSPOD(国内版)创建 token](https://support.dnspod.cn/Kb/showarticle/tsid/227/)
|
|
101
|
+
- [阿里云 accesskey](https://help.aliyun.com/document_detail/87745.htm)
|
|
102
|
+
- [DNS.COM API Key/Secret](https://www.dns.com/member/apiSet)
|
|
103
|
+
- [DNSPOD(国际版)](https://www.dnspod.com/docs/info.html#get-the-user-token)
|
|
104
|
+
- [CloudFlare API Key](https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key-)(除了 `email + API KEY`,也可使用 `Token`,需要列出 Zone 权限)
|
|
105
|
+
- [HE.net DDNS 文档](https://dns.he.net/docs.html)(仅需将设置的密码填入 `token` 字段,`id` 字段可留空)
|
|
106
|
+
- [华为 APIKEY 申请](https://console.huaweicloud.com/iam/)(点左边访问密钥,然后点新增访问密钥)
|
|
107
|
+
- 自定义回调的参数填写方式请查看下方的自定义回调配置说明
|
|
108
|
+
|
|
109
|
+
2. 修改配置文件,`ipv4` 和 `ipv6` 字段,为待更新的域名,详细参照配置说明
|
|
110
|
+
|
|
111
|
+
## 详细配置
|
|
112
|
+
|
|
113
|
+
所有字段可通过三种方式进行配置
|
|
114
|
+
|
|
115
|
+
1. 命令行参数 `ddns --key=value`(`ddns -h` 查看详情),优先级最高
|
|
116
|
+
2. JSON 配置文件(值为 null 认为是有效值,会覆盖环境变量的设置,如果没有对应的 key 则会尝试使用环境变量)
|
|
117
|
+
3. 环境变量 DDNS_ 前缀加上 key 全大写或者全小写,点转下划线(`${ddns_id}` 或 `${DDNS_ID}`,`${DDNS_LOG_LEVEL}`)
|
|
118
|
+
|
|
119
|
+
<details open>
|
|
120
|
+
<summary markdown="span">config.json 配置文件</summary>
|
|
121
|
+
|
|
122
|
+
- 首次运行会自动生成一个模板配置文件
|
|
123
|
+
- 可以使用 `-c` 使用指定的配置文件(默认读取当前目录的 config.json)
|
|
124
|
+
- 推荐使用 vscode 等支持 JsonSchema 的编辑器编辑配置文件
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ddns -c path/to/config.json
|
|
128
|
+
# 或者源码运行
|
|
129
|
+
python run.py -c /path/to/config.json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### 配置参数表
|
|
133
|
+
|
|
134
|
+
| key | type | required | default | description | tips |
|
|
135
|
+
| :------: | :----------------: | :------: | :---------: | :---------------: | ----------------------------------------------------------------------------------------------------------- |
|
|
136
|
+
| id | string | √ | 无 | api 访问 ID | Cloudflare 为邮箱(使用 Token 时留空)<br>HE.net 可留空<br>华为云为 Access Key ID (AK) |
|
|
137
|
+
| token | string | √ | 无 | api 授权 token | 部分平台叫 secret key,**反馈粘贴时删除** |
|
|
138
|
+
| dns | string | No | `"dnspod"` | dns 服务商 | 阿里 DNS 为 `alidns`,Cloudflare 为 `cloudflare`,dns.com 为 `dnscom`,DNSPOD 国内为 `dnspod`,DNSPOD 国际为 `dnspod_com`,HE.net 为 `he`,华为云为 `huaweidns`,自定义回调为 `callback` |
|
|
139
|
+
| ipv4 | array | No | `[]` | ipv4 域名列表 | 为 `[]` 时,不会获取和更新 IPv4 地址 |
|
|
140
|
+
| ipv6 | array | No | `[]` | ipv6 域名列表 | 为 `[]` 时,不会获取和更新 IPv6 地址 |
|
|
141
|
+
| index4 | string\|int\|array | No | `"default"` | ipv4 获取方式 | 可设置 `网卡`、`内网`、`公网`、`正则` 等方式 |
|
|
142
|
+
| index6 | string\|int\|array | No | `"default"` | ipv6 获取方式 | 可设置 `网卡`、`内网`、`公网`、`正则` 等方式 |
|
|
143
|
+
| ttl | number | No | `null` | DNS 解析 TTL 时间 | 不设置采用 DNS 默认策略 |
|
|
144
|
+
| proxy | string\|array | No | 无 | http 代理 `;` 分割 | 多代理逐个尝试直到成功,`DIRECT` 为直连 |
|
|
145
|
+
| ~~debug~~| bool | No | `false` | 是否开启调试 | v4 中弃用,请改用 log.level=DEBUG |
|
|
146
|
+
| cache | string\|bool | No | `true` | 是否缓存记录 | 正常情况打开避免频繁更新,默认位置为临时目录下 `ddns.cache`,也可以指定一个具体路径 |
|
|
147
|
+
| log | {"level":string,"file":string} | No | `null` | 日志配置(可选) | 日志配置,日志级别和路径(默认命令行),例如:`{ "level": "DEBUG", "file": "dns.log" }` |
|
|
148
|
+
|
|
149
|
+
#### index4 和 index6 参数说明
|
|
150
|
+
|
|
151
|
+
- 数字(`0`,`1`,`2`,`3`等):第 i 个网卡 ip
|
|
152
|
+
- 字符串 `"default"`(或者无此项):系统访问外网默认 IP
|
|
153
|
+
- 字符串 `"public"`:使用公网 ip(使用公网 API 查询,url 的简化模式)
|
|
154
|
+
- 字符串 `"url:xxx"`:打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
|
|
155
|
+
- 字符串 `"regex:xxx"` 正则表达(如 `"regex:192.*"`):提取 `ifconfig`/`ipconfig` 中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
|
|
156
|
+
- `"192.*"` 表示 192 开头的所有 ip(注意 `regex:` 不可省略)
|
|
157
|
+
- 如果想匹配 `10.00.xxxx` 应该写成 `"regex:10\\.00\\..*"`(`"\\"` json 转义成 `\`)
|
|
158
|
+
- 字符串 `"cmd:xxxx"`:执行命令 `xxxx` 的 stdout 输出结果作为目标 IP
|
|
159
|
+
- 字符串 `"shell:xxx"`:使用系统 shell 运行 `xxx`,并把结果 stdout 作为目标 IP
|
|
160
|
+
- `false`:强制禁止更新 ipv4 或 ipv6 的 DNS 解析
|
|
161
|
+
- 列表:依次执行列表中的 index 规则,并将最先获得的结果作为目标 IP
|
|
162
|
+
- 例如 `["public", "regex:172\\..*"]` 将先查询公网 API,未获取到 IP 后再从本地寻找 172 开头的 IP
|
|
163
|
+
|
|
164
|
+
#### 自定义回调配置说明
|
|
165
|
+
|
|
166
|
+
- `id` 字段填写回调地址,以 HTTP 或 HTTPS 开头,推荐采用 HTTPS 方式的回调 API ,当 `token` 字段非空且 URL 参数包含下表所示的常量字符串时,会自动替换为实际内容。
|
|
167
|
+
- `token` 字段为 POST 参数,本字段为空或不存在则使用 GET 方式发起回调,回调参数采用 JSON 格式编码,当 JSON 的首层参数值包含下表所示的常量字符串时,会自动替换为实际内容。
|
|
168
|
+
|
|
169
|
+
| 常量名称 | 常量内容 | 说明 |
|
|
170
|
+
| ---------------- | ---------------------- | -------- |
|
|
171
|
+
| `__DOMAIN__` | DDNS 域名 | |
|
|
172
|
+
| `__RECORDTYPE__` | DDNS 记录类型 | |
|
|
173
|
+
| `__TTL__` | DDNS TTL | |
|
|
174
|
+
| `__TIMESTAMP__` | 请求发起时间戳 | 包含小数 |
|
|
175
|
+
| `__IP__` | 获取的对应类型的 IP 地址 | |
|
|
176
|
+
|
|
177
|
+
#### 配置示例
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
|
|
182
|
+
"id": "12345",
|
|
183
|
+
"token": "mytokenkey",
|
|
184
|
+
"dns": "dnspod 或 dnspod_com 或 alidns 或 dnscom 或 cloudflare 或 he 或 huaweidns 或 callback",
|
|
185
|
+
"ipv4": ["ddns.newfuture.cc", "ipv4.ddns.newfuture.cc"],
|
|
186
|
+
"ipv6": ["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"],
|
|
187
|
+
"index4": 0,
|
|
188
|
+
"index6": "public",
|
|
189
|
+
"ttl": 600,
|
|
190
|
+
"proxy": "127.0.0.1:1080;DIRECT",
|
|
191
|
+
"log": {
|
|
192
|
+
"level": "DEBUG",
|
|
193
|
+
"file": "dns.log"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
</details>
|
|
198
|
+
|
|
199
|
+
## 定时任务
|
|
200
|
+
|
|
201
|
+
<details>
|
|
202
|
+
<summary markdown="span">可以通过脚本设置定时任务(默认每 5 分钟检查一次 IP,自动更新)</summary>
|
|
203
|
+
|
|
204
|
+
#### Windows
|
|
205
|
+
|
|
206
|
+
- [推荐] 以系统身份运行,右键“以管理员身份运行”`task.bat`(或者在管理员命令行中运行)
|
|
207
|
+
- 以当前用户身份运行定时任务,双击或运行 `task.bat`(执行时会闪黑框)
|
|
208
|
+
|
|
209
|
+
#### Linux
|
|
210
|
+
|
|
211
|
+
- 使用 init.d 和 crontab:
|
|
212
|
+
```bash
|
|
213
|
+
sudo ./task.sh
|
|
214
|
+
```
|
|
215
|
+
- 使用 systemd:
|
|
216
|
+
```bash
|
|
217
|
+
安装:
|
|
218
|
+
sudo ./systemd.sh install
|
|
219
|
+
卸载:
|
|
220
|
+
sudo ./systemd.sh uninstall
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
该脚本安装的文件符合 [Filesystem Hierarchy Standard (FHS)](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard):
|
|
224
|
+
可执行文件所在目录为 `/usr/share/DDNS`
|
|
225
|
+
配置文件所在目录为 `/etc/DDNS`
|
|
226
|
+
|
|
227
|
+
#### Docker
|
|
228
|
+
|
|
229
|
+
Docker 镜像在无额外参数的情况下,已默认启用每 5 分钟执行一次的定时任务
|
|
230
|
+
|
|
231
|
+
</details>
|
|
232
|
+
|
|
233
|
+
## FAQ
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
<summary markdown="span">Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]</summary>
|
|
237
|
+
|
|
238
|
+
> Windows Server 默认安全策略会禁止任何未添加的信任 SSL 证书,可手动添加一下对应的证书 [#56](https://github.com/NewFuture/DDNS/issues/56#issuecomment-487371078)
|
|
239
|
+
|
|
240
|
+
使用系统自带的 IE 浏览器访问一次对应的 API 即可
|
|
241
|
+
|
|
242
|
+
- alidns 打开: <https://alidns.aliyuncs.com>
|
|
243
|
+
- cloudflare 打开: <https://api.cloudflare.com>
|
|
244
|
+
- dns.com 打开: <https://www.dns.com>
|
|
245
|
+
- dnspod.cn 打开: <https://dnsapi.cn>
|
|
246
|
+
- dnspod 国际版: <https://api.dnspod.com>
|
|
247
|
+
- 华为 DNS <https://dns.myhuaweicloud.com>
|
|
248
|
+
</details>
|
|
249
|
+
|
|
250
|
+
<details>
|
|
251
|
+
<summary markdown="span">问题排查反馈</summary>
|
|
252
|
+
|
|
253
|
+
1. 先确认排查是否是系统/网络环境问题
|
|
254
|
+
2. 在 [issues](https://github.com/NewFuture/DDNS/issues) 中搜索是否有类似问题
|
|
255
|
+
3. 前两者均无法解决或者确定是 bug,[在此新建 issue](https://github.com/NewFuture/DDNS/issues/new)
|
|
256
|
+
- [ ] 开启 debug 配置
|
|
257
|
+
- [ ] 附上这些内容 **运行版本和方式**、**系统环境**、**出错日志**、**去掉 id/token** 的配置文件
|
|
258
|
+
- [ ] 源码运行注明使用的 python 环境
|
|
259
|
+
|
|
260
|
+
</details>
|