diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/AgentClusterInfo.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/AgentClusterInfo.java index 0efeac84ac..070e5f4d28 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/AgentClusterInfo.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/AgentClusterInfo.java @@ -13,19 +13,21 @@ public class AgentClusterInfo { private String arthasVersion; /** - * agent 连接到的 tunnel server 的ip + * agent 连接到的 tunnel server 的ip 和 port */ private String clientConnectHost; + private int clientConnectTunnelPort; public AgentClusterInfo() { } - public AgentClusterInfo(AgentInfo agentInfo, String clientConnectHost) { + public AgentClusterInfo(AgentInfo agentInfo, String clientConnectHost, int clientConnectTunnelPort) { this.host = agentInfo.getHost(); this.port = agentInfo.getPort(); this.arthasVersion = agentInfo.getArthasVersion(); this.clientConnectHost = clientConnectHost; + this.clientConnectTunnelPort = clientConnectTunnelPort; } public String getHost() { @@ -60,4 +62,12 @@ public void setClientConnectHost(String clientConnectHost) { this.clientConnectHost = clientConnectHost; } + public int getClientConnectTunnelPort() { + return clientConnectTunnelPort; + } + + public void setClientConnectTunnelPort(int clientConnectTunnelPort) { + this.clientConnectTunnelPort = clientConnectTunnelPort; + } + } diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/TunnelServer.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/TunnelServer.java index 67b57723f3..ff86172808 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/TunnelServer.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/TunnelServer.java @@ -97,7 +97,7 @@ public void run() { if (tunnelClusterStore != null && clientConnectHost != null) { try { for (Entry entry : agentInfoMap.entrySet()) { - tunnelClusterStore.addAgent(entry.getKey(), new AgentClusterInfo(entry.getValue(), clientConnectHost), 60 * 60, TimeUnit.SECONDS); + tunnelClusterStore.addAgent(entry.getKey(), new AgentClusterInfo(entry.getValue(), clientConnectHost, port), 60 * 60, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("update tunnel info error", t); @@ -123,7 +123,7 @@ public Optional findAgent(String id) { public void addAgent(String id, AgentInfo agentInfo) { agentInfoMap.put(id, agentInfo); if (this.tunnelClusterStore != null) { - this.tunnelClusterStore.addAgent(id, new AgentClusterInfo(agentInfo, clientConnectHost), 60 * 60, TimeUnit.SECONDS); + this.tunnelClusterStore.addAgent(id, new AgentClusterInfo(agentInfo, clientConnectHost, port), 60 * 60, TimeUnit.SECONDS); } } diff --git a/web-ui/arthasWebConsole/all/tunnel/src/Agent.vue b/web-ui/arthasWebConsole/all/tunnel/src/Agent.vue index bbfde0039d..772bb0e1d9 100644 --- a/web-ui/arthasWebConsole/all/tunnel/src/Agent.vue +++ b/web-ui/arthasWebConsole/all/tunnel/src/Agent.vue @@ -6,8 +6,8 @@ function getUrlParam(name: string) { const urlparam = new URLSearchParams(window.location.search) return urlparam.get(name) } -function tunnelWebConsoleLink(agentId: string, targetServer: string) { - return `/?targetServer=${targetServer}&agentId=${agentId}`; +function tunnelWebConsoleLink(agentId: string, tunnelPort: number, targetServer: string) { + return `/?targetServer=${targetServer}&port=${tunnelPort}&agentId=${agentId}`; } const fetchMyApps = () => { @@ -44,7 +44,7 @@ onMounted(() => { {{ + :href="tunnelWebConsoleLink(agentInfoRecord[0], agentInfoRecord[1].clientConnectTunnelPort, agentInfoRecord[1].clientConnectHost)">{{ agentInfoRecord[1].host }} diff --git a/web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts b/web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts index 6b79347810..f846c582c1 100644 --- a/web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts +++ b/web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts @@ -2,5 +2,6 @@ type AgentInfo = { clientConnectHost:string, host:string, port:number, + clientConnectTunnelPort:number, arthasVersion:string } \ No newline at end of file