nonebot-plugin-mccheck 0.2.3__tar.gz → 0.2.4__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.
Files changed (17) hide show
  1. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/PKG-INFO +1 -1
  2. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/configs.py +1 -1
  3. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/utils.py +14 -11
  4. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/pyproject.toml +1 -1
  5. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/LICENSE +0 -0
  6. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/README.md +0 -0
  7. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/__init__.py +0 -0
  8. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/config.py +0 -0
  9. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/data_source.py +0 -0
  10. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/language.json +0 -0
  11. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/Minecraft_AE.ttf +0 -0
  12. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/README.md +0 -0
  13. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/background.png +0 -0
  14. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/default.html +0 -0
  15. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/imagelesshoverbg.png +0 -0
  16. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/main.css +0 -0
  17. {nonebot_plugin_mccheck-0.2.3 → nonebot_plugin_mccheck-0.2.4}/nonebot_plugin_mccheck/templates/no_favicon.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-mccheck
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Minecraft服务器状态查询的nonebot插件,支持IPv6/Minecraft server status query plugin for nonebot, IPv6 supported
5
5
  License: GPL-3.0
6
6
  License-File: LICENSE
@@ -15,4 +15,4 @@ def readInfo(file: str) -> dict:
15
15
  message_type = plugin_config.type
16
16
  lang = plugin_config.language
17
17
  lang_data = readInfo("language.json")
18
- VERSION = "0.2.3"
18
+ VERSION = "0.2.4"
@@ -8,6 +8,7 @@ from typing import Literal
8
8
 
9
9
  import dns.asyncresolver
10
10
  import dns.exception
11
+ import dns.name
11
12
  import dns.resolver
12
13
  import idna
13
14
  from nonebot import logger, require
@@ -289,21 +290,23 @@ def is_validity_address(address: str) -> bool:
289
290
 
290
291
  def is_domain(address: str) -> bool:
291
292
  """
292
- 判断给定的地址是否为域名。
293
+ 判断给定的地址是否为合法域名。
293
294
 
294
- :params address: 需要验证的地址。
295
-
296
- :returns: 如果地址为域名则返回True,否则返回False。
295
+ :param str address: 待验证的域名字符串。
296
+ :returns: 如果合法返回 True,否则返回 False。
297
+ :rtype: bool
297
298
  """
298
299
  try:
299
- punycode_address = idna.encode(address).decode("utf-8")
300
- except idna.IDNAError:
301
- return False
300
+ # 尝试构造 DNS Name 对象
301
+ name = dns.name.from_text(address)
302
302
 
303
- domain_pattern = re.compile(
304
- r"^(?!-)(?:[A-Za-z0-9-]{1,63}\.)+(?:[A-Za-z]{2,}|xn--[A-Za-z0-9-]{2,})$|^(localhost)$"
305
- )
306
- return bool(domain_pattern.match(punycode_address))
303
+ # 检查总长度是否符合 RFC (<= 253)
304
+ if len(name.to_unicode()) > 253:
305
+ return False
306
+
307
+ return all(len(label) <= 63 for label in name.labels)
308
+ except Exception:
309
+ return False
307
310
 
308
311
 
309
312
  def is_ipv4(address: str) -> bool:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-mccheck"
3
- version = "0.2.3"
3
+ version = "0.2.4"
4
4
  description = "Minecraft服务器状态查询的nonebot插件,支持IPv6/Minecraft server status query plugin for nonebot, IPv6 supported"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"