ddns 3.0.2__tar.gz → 3.1.2__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.

@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ddns
3
- Version: 3.0.2
3
+ Version: 3.1.2
4
4
  Summary: automatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]
5
5
  Home-page: https://ddns.newfuture.cc
6
6
  Author: NewFuture
@@ -18,6 +18,19 @@ Classifier: Programming Language :: Python :: 3
18
18
  Requires-Python: >=2.5, <4
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: keywords
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: platform
31
+ Dynamic: project-url
32
+ Dynamic: requires-python
33
+ Dynamic: summary
21
34
 
22
35
  # [DDNS](https://github.com/NewFuture/DDNS)
23
36
 
@@ -161,13 +174,13 @@ python run.py -c /path/to/config.json
161
174
  - 字符串`"public"`: 使用公网 ip(使用公网 API 查询,url 的简化模式)
162
175
  - 字符串`"url:xxx"`: 打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
163
176
  - 字符串`"regex:xxx"` 正则表达(如`"regex:192.*"`): 提取`ifconfig`/`ipconfig`中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
164
- - `"192.*"`表示 192 开头的所有 ip
165
- - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..\*"`(`"\\"`json 转义成`\`)
177
+ - `"192.*"`表示 192 开头的所有 ip (注意`regex:`不可省略)
178
+ - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..*"` (`"\\"` json 转义成`\`)
166
179
  - 字符串`"cmd:xxxx"`: 执行命令`xxxx`的 stdout 输出结果作为目标 IP
167
180
  - 字符串`"shell:xxx"`: 使用系统 shell 运行`xxx`,并把结果 stdout 作为目标 IP
168
181
  - `false`: 强制禁止更新 ipv4 或 ipv6 的 DNS 解析
169
182
  - 列表:依次执行列表中的index规则,并将最先获得的结果作为目标 IP
170
- - 例如`["public", "172.*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
183
+ - 例如`["public", "regex:172\\..*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
171
184
 
172
185
  #### 自定义回调配置说明
173
186
 
@@ -140,13 +140,13 @@ python run.py -c /path/to/config.json
140
140
  - 字符串`"public"`: 使用公网 ip(使用公网 API 查询,url 的简化模式)
141
141
  - 字符串`"url:xxx"`: 打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
142
142
  - 字符串`"regex:xxx"` 正则表达(如`"regex:192.*"`): 提取`ifconfig`/`ipconfig`中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
143
- - `"192.*"`表示 192 开头的所有 ip
144
- - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..\*"`(`"\\"`json 转义成`\`)
143
+ - `"192.*"`表示 192 开头的所有 ip (注意`regex:`不可省略)
144
+ - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..*"` (`"\\"` json 转义成`\`)
145
145
  - 字符串`"cmd:xxxx"`: 执行命令`xxxx`的 stdout 输出结果作为目标 IP
146
146
  - 字符串`"shell:xxx"`: 使用系统 shell 运行`xxx`,并把结果 stdout 作为目标 IP
147
147
  - `false`: 强制禁止更新 ipv4 或 ipv6 的 DNS 解析
148
148
  - 列表:依次执行列表中的index规则,并将最先获得的结果作为目标 IP
149
- - 例如`["public", "172.*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
149
+ - 例如`["public", "regex:172\\..*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
150
150
 
151
151
  #### 自定义回调配置说明
152
152
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ddns
3
- Version: 3.0.2
3
+ Version: 3.1.2
4
4
  Summary: automatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]
5
5
  Home-page: https://ddns.newfuture.cc
6
6
  Author: NewFuture
@@ -18,6 +18,19 @@ Classifier: Programming Language :: Python :: 3
18
18
  Requires-Python: >=2.5, <4
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: keywords
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: platform
31
+ Dynamic: project-url
32
+ Dynamic: requires-python
33
+ Dynamic: summary
21
34
 
22
35
  # [DDNS](https://github.com/NewFuture/DDNS)
23
36
 
@@ -161,13 +174,13 @@ python run.py -c /path/to/config.json
161
174
  - 字符串`"public"`: 使用公网 ip(使用公网 API 查询,url 的简化模式)
162
175
  - 字符串`"url:xxx"`: 打开 URL `xxx`(如:`"url:http://ip.sb"`),从返回的数据提取 IP 地址
163
176
  - 字符串`"regex:xxx"` 正则表达(如`"regex:192.*"`): 提取`ifconfig`/`ipconfig`中与之匹配的首个 IP 地址,**注意 json 转义**(`\`要写成`\\`)
164
- - `"192.*"`表示 192 开头的所有 ip
165
- - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..\*"`(`"\\"`json 转义成`\`)
177
+ - `"192.*"`表示 192 开头的所有 ip (注意`regex:`不可省略)
178
+ - 如果想匹配`10.00.xxxx`应该写成`"regex:10\\.00\\..*"` (`"\\"` json 转义成`\`)
166
179
  - 字符串`"cmd:xxxx"`: 执行命令`xxxx`的 stdout 输出结果作为目标 IP
167
180
  - 字符串`"shell:xxx"`: 使用系统 shell 运行`xxx`,并把结果 stdout 作为目标 IP
168
181
  - `false`: 强制禁止更新 ipv4 或 ipv6 的 DNS 解析
169
182
  - 列表:依次执行列表中的index规则,并将最先获得的结果作为目标 IP
170
- - 例如`["public", "172.*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
183
+ - 例如`["public", "regex:172\\..*"]`将先查询公网API,未获取到IP后再从本地寻找172开头的IP
171
184
 
172
185
  #### 自定义回调配置说明
173
186
 
@@ -18,7 +18,7 @@ from util import ip
18
18
  from util.cache import Cache
19
19
  from util.config import init_config, get_config
20
20
 
21
- __version__ = "v3.0.2@2024-06-13T12:25:13+00:00" # CI 时会被Tag替换
21
+ __version__ = "v3.1.2@2025-04-09T12:53:42+00:00" # CI 时会被Tag替换
22
22
  __description__ = "automatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]"
23
23
  __doc__ = """
24
24
  ddns[%s]
@@ -27,7 +27,7 @@ ddns[%s]
27
27
  Copyright (c) New Future (MIT License)
28
28
  """ % (__version__)
29
29
 
30
- environ["DDNS_VERSION"] = "v3.0.2"
30
+ environ["DDNS_VERSION"] = "v3.1.2"
31
31
 
32
32
  if getattr(sys, 'frozen', False):
33
33
  # https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OpenSSL-Certificate
@@ -39,31 +39,35 @@ def get_ip(ip_type, index="default"):
39
39
  """
40
40
  get IP address
41
41
  """
42
- if index is False: # disabled
43
- return False
44
- elif type(index) is list: # 如果获取到的规则是列表,则依次判断列表中每一个规则,直到找到一个可以正确获取到的IP
45
- value = None
46
- for i in index:
47
- value = get_ip(ip_type, i)
48
- if value:
49
- break
50
- elif str(index).isdigit(): # 数字 local eth
51
- value = getattr(ip, "local_v" + ip_type)(index)
52
- elif index.startswith('cmd:'): # cmd
53
- value = str(check_output(index[4:]).strip().decode('utf-8'))
54
- elif index.startswith('shell:'): # shell
55
- value = str(check_output(
56
- index[6:], shell=True).strip().decode('utf-8'))
57
- elif index.startswith('url:'): # 自定义 url
58
- value = getattr(ip, "public_v" + ip_type)(index[4:])
59
- elif index.startswith('regex:'): # 正则 regex
60
- value = getattr(ip, "regex_v" + ip_type)(index[6:])
61
- elif any((c in index) for c in '*.:'): # 兼容 regex
62
- value = getattr(ip, "regex_v" + ip_type)(index)
63
- else:
64
- value = getattr(ip, index + "_v" + ip_type)()
65
-
66
- return value
42
+ # CN: 捕获异常
43
+ # EN: Catch exceptions
44
+ value = None
45
+ try:
46
+ debug(f"get_ip({ip_type}, {index})")
47
+ if index is False: # disabled
48
+ return False
49
+ elif type(index) is list: # 如果获取到的规则是列表,则依次判断列表中每一个规则,直到找到一个可以正确获取到的IP
50
+ for i in index:
51
+ value = get_ip(ip_type, i)
52
+ if value:
53
+ break
54
+ elif str(index).isdigit(): # 数字 local eth
55
+ value = getattr(ip, "local_v" + ip_type)(index)
56
+ elif index.startswith('cmd:'): # cmd
57
+ value = str(check_output(index[4:]).strip().decode('utf-8'))
58
+ elif index.startswith('shell:'): # shell
59
+ value = str(check_output(
60
+ index[6:], shell=True).strip().decode('utf-8'))
61
+ elif index.startswith('url:'): # 自定义 url
62
+ value = getattr(ip, "public_v" + ip_type)(index[4:])
63
+ elif index.startswith('regex:'): # 正则 regex
64
+ value = getattr(ip, "regex_v" + ip_type)(index[6:])
65
+ else:
66
+ value = getattr(ip, index + "_v" + ip_type)()
67
+ except Exception as e:
68
+ error(e)
69
+ finally:
70
+ return value
67
71
 
68
72
 
69
73
  def change_dns_record(dns, proxy_list, **kw):
@@ -69,7 +69,7 @@ def __load_config(path="config.json", skip_auto_generation=False):
69
69
  """
70
70
  加载配置
71
71
  """
72
- global __config, config_modified_time
72
+ global __config
73
73
  try:
74
74
  with open(path) as configfile:
75
75
  __config = loadjson(configfile)
@@ -74,7 +74,7 @@ def _ip_regex_match(parrent_regex, match_regex):
74
74
  if os_name == 'nt': # windows:
75
75
  cmd = 'ipconfig'
76
76
  else:
77
- cmd = 'ifconfig 2>/dev/null || ip address'
77
+ cmd = 'ip address || ifconfig 2>/dev/null'
78
78
 
79
79
  for s in popen(cmd).readlines():
80
80
  addr = ip_pattern.search(s)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes