@lsby/cloudflare-ipv6-ddns 0.0.4 → 0.0.6

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 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
- export CLOUDFLARE_API_TOKEN=<你的token>
15
- export CLOUDFLARE_ZONE_ID=<域名的区域id>
16
- export DOMAIN=<要设置ddns的完整域名>
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];
@@ -23,6 +24,9 @@ async function 增加或更新dns记录(cf句柄, 区域id, 域名, ip地址,
23
24
  console.log('没有找到域名%O对应的记录, 将新增该记录...', 域名);
24
25
  await cf句柄.dns.records.create({
25
26
  zone_id: 区域id,
27
+ // 2024年7月3日 发现参数名称改成了body_zone_id
28
+ // @ts-ignore
29
+ body_zone_id: 区域id,
26
30
  content: ip地址,
27
31
  name: 域名,
28
32
  proxied: 使用代理,
@@ -43,6 +47,9 @@ async function 增加或更新dns记录(cf句柄, 区域id, 域名, ip地址,
43
47
  console.log('找到域名%O对应的记录, 发现ip有变化, 将修改该记录', 域名);
44
48
  await cf句柄.dns.records.edit(目标.id, {
45
49
  zone_id: 区域id,
50
+ // 2024年7月3日 发现参数名称改成了body_zone_id
51
+ // @ts-ignore
52
+ body_zone_id: 区域id,
46
53
  content: ip地址,
47
54
  name: 域名,
48
55
  // 截至 2024年5月2日, 接口实际返回的值包括proxiable和proxied, proxiable总为true, 所以这里使用proxied.
@@ -61,9 +68,10 @@ async function main() {
61
68
  const 区域id = process.env['CLOUDFLARE_ZONE_ID'];
62
69
  const 域名 = process.env['DOMAIN'];
63
70
  if (!令牌 || !区域id || !域名) {
64
- console.log('未提供必要的环境变量:CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, DOMAIN, UPDATE_TIME');
71
+ console.log('未提供必要的环境变量:CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, DOMAIN');
65
72
  process.exit(1);
66
73
  }
74
+ console.log('传入信息: 区域id: %o, 域名: %o', 区域id, 域名);
67
75
  const cloudflare = new Cloudflare({ apiToken: 令牌 });
68
76
  const ipv6地址 = await 获取IPv6地址();
69
77
  await 增加或更新dns记录(cloudflare, 区域id, 域名, ipv6地址, 'AAAA');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsby/cloudflare-ipv6-ddns",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "lsby-cloudflare-ipv6-ddns": "dist/index.js"