Skip to content

Commit

Permalink
Fix the page redirection issue of Arthas tunnel server
Browse files Browse the repository at this point in the history
  • Loading branch information
ygjia authored and hengyunabc committed Jul 6, 2023
1 parent 0b29b7d commit 0bf9fc5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void run() {
if (tunnelClusterStore != null && clientConnectHost != null) {
try {
for (Entry<String, AgentInfo> 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);
Expand All @@ -123,7 +123,7 @@ public Optional<AgentInfo> 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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions web-ui/arthasWebConsole/all/tunnel/src/Agent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -44,7 +44,7 @@ onMounted(() => {
<tr v-for="(agentInfoRecord) in agentInfos" :key="agentInfoRecord[0]" class="hover">
<td>
<a class="btn btn-primary btn-sm"
:href="tunnelWebConsoleLink(agentInfoRecord[0], agentInfoRecord[1].clientConnectHost)">{{
:href="tunnelWebConsoleLink(agentInfoRecord[0], agentInfoRecord[1].clientConnectTunnelPort, agentInfoRecord[1].clientConnectHost)">{{
agentInfoRecord[1].host
}}</a>
</td>
Expand Down
1 change: 1 addition & 0 deletions web-ui/arthasWebConsole/all/tunnel/tunnel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ type AgentInfo = {
clientConnectHost:string,
host:string,
port:number,
clientConnectTunnelPort:number,
arthasVersion:string
}

0 comments on commit 0bf9fc5

Please sign in to comment.