Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the page redirection issue of Arthas tunnel server #2572 #2573

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}