Skip to content

chore: TCP ping now uses configured interface for accurate testing#396

Draft
Alex-WU-Gen-9-png wants to merge 3 commits intoSagit-chu:mainfrom
Alex-WU-Gen-9-png:main
Draft

chore: TCP ping now uses configured interface for accurate testing#396
Alex-WU-Gen-9-png wants to merge 3 commits intoSagit-chu:mainfrom
Alex-WU-Gen-9-png:main

Conversation

@Alex-WU-Gen-9-png
Copy link
Copy Markdown
Contributor

现象:之前的误解是由于——即使配置了 eth2 作为出口接口,面板转发页面的"测试"按钮仍使用默认网络路径进行 TCP ping。
根因TcpPing 命令不支持接口绑定参数。

  • TcpPingRequest 结构体无 interface 字段
  • tcpPingHost 函数使用 net.DialTimeout 直连,无法指定本地地址
  • 后端 tcpPingViaNode 未读取节点的 interfaceName 配置

Temped Solution:
Agent 端 (go-gost/x/socket/websocket_reporter.go):

  • TcpPingRequest 添加 Interface 字段
  • tcpPingHost 改用 net.Dialer + LocalAddr 绑定接口 IP
    Backend 端:
  • tcpPingViaNode 从 node.InterfaceName 读取配置并传递
  • tcpPingViaRemoteNode 支持 Federation 场景
  • Federation diagnose 请求添加 interface 字段

📊 Data Flow (After Fix)
Panel 测试按钮

tcpPingViaNode(node, ip, port)
↓ 读取 node.InterfaceName = "eth2"
TcpPing { ip, port, interface: "eth2" }
↓ WebSocket
Agent handleTcpPing
↓ net.InterfaceByName("eth2")
↓ 获取接口 IP
net.Dialer{ LocalAddr: 192.168.1.100:0 }

dialer.Dial("tcp", target) ← 使用指定接口出口

Alex-WU-Gen-9-png and others added 3 commits March 29, 2026 20:38
- Add missing interfaceName field to node list API response map
- Fixes bug where interface name value disappears after page refresh
- Field is correctly saved to DB but was not returned in API response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant