Skip to content

Commit be646f7

Browse files
ygjiahengyunabc
authored andcommitted
Fix the page redirection issue of Arthas tunnel server
1 parent bad7f07 commit be646f7

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/AgentClusterInfo.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ public class AgentClusterInfo {
1313
private String arthasVersion;
1414

1515
/**
16-
* agent 连接到的 tunnel server 的ip
16+
* agent 连接到的 tunnel server 的ip 和 port
1717
*/
1818
private String clientConnectHost;
19+
private int clientConnectTunnelPort;
1920

2021
public AgentClusterInfo() {
2122

2223
}
2324

24-
public AgentClusterInfo(AgentInfo agentInfo, String clientConnectHost) {
25+
public AgentClusterInfo(AgentInfo agentInfo, String clientConnectHost, int clientConnectTunnelPort) {
2526
this.host = agentInfo.getHost();
2627
this.port = agentInfo.getPort();
2728
this.arthasVersion = agentInfo.getArthasVersion();
2829
this.clientConnectHost = clientConnectHost;
30+
this.clientConnectTunnelPort = clientConnectTunnelPort;
2931
}
3032

3133
public String getHost() {
@@ -60,4 +62,12 @@ public void setClientConnectHost(String clientConnectHost) {
6062
this.clientConnectHost = clientConnectHost;
6163
}
6264

65+
public int getClientConnectTunnelPort() {
66+
return clientConnectTunnelPort;
67+
}
68+
69+
public void setClientConnectTunnelPort(int clientConnectTunnelPort) {
70+
this.clientConnectTunnelPort = clientConnectTunnelPort;
71+
}
72+
6373
}

tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/TunnelServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void run() {
9797
if (tunnelClusterStore != null && clientConnectHost != null) {
9898
try {
9999
for (Entry<String, AgentInfo> entry : agentInfoMap.entrySet()) {
100-
tunnelClusterStore.addAgent(entry.getKey(), new AgentClusterInfo(entry.getValue(), clientConnectHost), 60 * 60, TimeUnit.SECONDS);
100+
tunnelClusterStore.addAgent(entry.getKey(), new AgentClusterInfo(entry.getValue(), clientConnectHost, port), 60 * 60, TimeUnit.SECONDS);
101101
}
102102
} catch (Throwable t) {
103103
logger.error("update tunnel info error", t);
@@ -123,7 +123,7 @@ public Optional<AgentInfo> findAgent(String id) {
123123
public void addAgent(String id, AgentInfo agentInfo) {
124124
agentInfoMap.put(id, agentInfo);
125125
if (this.tunnelClusterStore != null) {
126-
this.tunnelClusterStore.addAgent(id, new AgentClusterInfo(agentInfo, clientConnectHost), 60 * 60, TimeUnit.SECONDS);
126+
this.tunnelClusterStore.addAgent(id, new AgentClusterInfo(agentInfo, clientConnectHost, port), 60 * 60, TimeUnit.SECONDS);
127127
}
128128
}
129129

web-ui/arthasWebConsole/all/tunnel/src/Agent.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function getUrlParam(name: string) {
66
const urlparam = new URLSearchParams(window.location.search)
77
return urlparam.get(name)
88
}
9-
function tunnelWebConsoleLink(agentId: string, targetServer: string) {
10-
return `/?targetServer=${targetServer}&agentId=${agentId}`;
9+
function tunnelWebConsoleLink(agentId: string, tunnelPort: number, targetServer: string) {
10+
return `/?targetServer=${targetServer}&port=${tunnelPort}&agentId=${agentId}`;
1111
}
1212
1313
const fetchMyApps = () => {
@@ -44,7 +44,7 @@ onMounted(() => {
4444
<tr v-for="(agentInfoRecord) in agentInfos" :key="agentInfoRecord[0]" class="hover">
4545
<td>
4646
<a class="btn btn-primary btn-sm"
47-
:href="tunnelWebConsoleLink(agentInfoRecord[0], agentInfoRecord[1].clientConnectHost)">{{
47+
:href="tunnelWebConsoleLink(agentInfoRecord[0], agentInfoRecord[1].clientConnectTunnelPort, agentInfoRecord[1].clientConnectHost)">{{
4848
agentInfoRecord[1].host
4949
}}</a>
5050
</td>

web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ type AgentInfo = {
22
clientConnectHost:string,
33
host:string,
44
port:number,
5+
clientConnectTunnelPort:number,
56
arthasVersion:string
67
}

0 commit comments

Comments
 (0)