dabfc128b3
- 3389远程页 + guacd 侧车 WebSocket 桥(无 RDP 会话审计) - 文件推送完成独立提示音,至少一台成功即播放 - 子机列表展开 CPU/内存/磁盘 sparkline 与指标采样落库 - 终端全量服务器列表、连接中状态;告警 Telegram 公网 IP - SSH 密钥凭据 UI 简化;子机搜索未设路径筛选 Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Server alert IP resolution for Telegram."""
|
|
|
|
from server.utils.server_alert_ips import (
|
|
classify_domain_ip,
|
|
format_alert_ip_line,
|
|
is_public_ip,
|
|
merge_alert_ips,
|
|
)
|
|
|
|
|
|
def test_is_public_ip():
|
|
assert is_public_ip("8.8.8.8") is True
|
|
assert is_public_ip("172.21.171.82") is False
|
|
|
|
|
|
def test_classify_domain_ip():
|
|
assert classify_domain_ip("8.8.8.8") == ("8.8.8.8", None)
|
|
assert classify_domain_ip("172.21.171.82") == (None, "172.21.171.82")
|
|
assert classify_domain_ip("host.example.com") == (None, None)
|
|
|
|
|
|
def test_merge_alert_ips_prefers_domain_public_over_agent():
|
|
pub, priv = merge_alert_ips(
|
|
domain="120.79.11.13",
|
|
system_info={"public_ip": "1.2.3.4", "private_ip": "172.21.171.82"},
|
|
)
|
|
assert pub == "120.79.11.13"
|
|
assert priv == "172.21.171.82"
|
|
|
|
|
|
def test_merge_alert_ips_agent_public_when_domain_private():
|
|
pub, priv = merge_alert_ips(
|
|
domain="172.21.171.82",
|
|
system_info={"public_ip": "120.79.11.13", "private_ip": "172.21.171.82"},
|
|
)
|
|
assert pub == "120.79.11.13"
|
|
assert priv == "172.21.171.82"
|
|
|
|
|
|
def test_format_alert_ip_line():
|
|
assert format_alert_ip_line("1.2.3.4", "10.0.0.1") == "IP地址:1.2.3.4(外) 10.0.0.1(内)"
|