feat(api): add server IP display for exchange whitelist configuration (#520)

Added functionality to display server public IP address for users to configure exchange API whitelists, specifically for Binance integration.

Backend changes (api/server.go):
- Add GET /api/server-ip endpoint requiring authentication
- Implement getPublicIPFromAPI() with fallback to multiple IP services
- Implement getPublicIPFromInterface() for local network interface detection
- Add isPrivateIP() helper to filter private IP addresses
- Import net package for IP address handling

Frontend changes (web/):
- Add getServerIP() API method in api.ts
- Display server IP in ExchangeConfigModal for Binance
- Add IP copy-to-clipboard functionality
- Load and display server IP when Binance exchange is selected
- Add i18n translations (en/zh) for whitelist IP messages:
  - whitelistIP, whitelistIPDesc, serverIPAddresses
  - copyIP, ipCopied, loadingServerIP

User benefits:
- Simplifies Binance API whitelist configuration
- Shows exact server IP to add to exchange whitelist
- One-click IP copy for convenience

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
Sue
2025-11-05 18:15:33 +08:00
committed by GitHub
parent 4c14880887
commit 5425f6a4ea
4 changed files with 221 additions and 3 deletions

View File

@@ -327,4 +327,16 @@ export const api = {
})
if (!res.ok) throw new Error('保存用户信号源配置失败')
},
}
// 获取服务器IP需要认证用于白名单配置
async getServerIP(): Promise<{
public_ip: string;
message: string;
}> {
const res = await fetch(`${API_BASE}/server-ip`, {
headers: getAuthHeaders(),
});
if (!res.ok) throw new Error('获取服务器IP失败');
return res.json();
},
};