Files
dns-server/.trae/documents/实现客户端IP地址位置显示.md
2026-01-14 23:08:46 +08:00

18 lines
825 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1. **更新getIpGeolocation函数**修改函数逻辑使用API响应中的addr字段来显示完整的地理位置信息
2. **处理编码问题**:确保正确处理中文编码
3. **维护缓存机制**保留现有的24小时缓存机制提高性能
4. **测试不同IP类型**确保公网IP和内网IP都能正确显示
### 具体修改点
- **文件**`/root/dns/static/js/logs.js`
- **函数**`getIpGeolocation`
- **修改内容**
- 从API响应中提取`addr`字段
- 直接使用addr字段作为完整的地理位置信息
- 保持对私有IP的特殊处理
- 维护现有的缓存机制
### 预期效果
- 公网IP显示格式"IP地址 (完整地理位置来自addr字段)"
- 内网IP显示格式"IP地址 (内网 内网)"
- 未知IP显示格式"IP地址 (未知 未知)"