@lsby/cloudflare-ipv6-ddns 0.0.4 → 0.0.5
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.
- package/README.md +10 -4
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,18 @@
|
|
|
8
8
|
npm i -g @lsby/cloudflare-ipv6-ddns
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
在命令行执行以下命令, windows和linux略有不同.
|
|
14
|
+
|
|
15
|
+
- 设置环境变量的写法不同, windows是`set`, linux是`export`.
|
|
16
|
+
|
|
17
|
+
下面的示例使用windows的写法:
|
|
12
18
|
|
|
13
19
|
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
set CLOUDFLARE_API_TOKEN=<cloudflare的token>
|
|
21
|
+
set CLOUDFLARE_ZONE_ID=<cloudflare域名的区域id>
|
|
22
|
+
set DOMAIN=<要设置ddns的完整域名>
|
|
17
23
|
|
|
18
24
|
lsby-cloudflare-ipv6-ddns
|
|
19
25
|
```
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ async function 获取IPv6地址() {
|
|
|
16
16
|
}
|
|
17
17
|
async function 增加或更新dns记录(cf句柄, 区域id, 域名, ip地址, 类型, 使用代理 = false, ttl = 1) {
|
|
18
18
|
console.log('开始增加或修改dns记录...');
|
|
19
|
+
console.log('传入信息: %o', { 区域id, 域名, ip地址, 类型, 使用代理, ttl });
|
|
19
20
|
console.log('查询dns记录列表...');
|
|
20
21
|
const 列表 = await cf句柄.dns.records.list({ zone_id: 区域id });
|
|
21
22
|
var 目标 = 列表.result.filter((a) => a.name == 域名)[0];
|
|
@@ -61,9 +62,10 @@ async function main() {
|
|
|
61
62
|
const 区域id = process.env['CLOUDFLARE_ZONE_ID'];
|
|
62
63
|
const 域名 = process.env['DOMAIN'];
|
|
63
64
|
if (!令牌 || !区域id || !域名) {
|
|
64
|
-
console.log('未提供必要的环境变量:CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, DOMAIN
|
|
65
|
+
console.log('未提供必要的环境变量:CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, DOMAIN');
|
|
65
66
|
process.exit(1);
|
|
66
67
|
}
|
|
68
|
+
console.log('传入信息: 区域id: %o, 域名: %o', 区域id, 域名);
|
|
67
69
|
const cloudflare = new Cloudflare({ apiToken: 令牌 });
|
|
68
70
|
const ipv6地址 = await 获取IPv6地址();
|
|
69
71
|
await 增加或更新dns记录(cloudflare, 区域id, 域名, ipv6地址, 'AAAA');
|