Skip to content

Commit 7b0588c

Browse files
committed
fix(app): handle IPv6 addresses in socket formatting
1 parent e48b678 commit 7b0588c

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

app/src/composables/useUpstreamStatus.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,36 @@ export function useUpstreamStatus(envGroupId?: Ref<number | undefined>) {
8686
return onlineCount
8787
}
8888

89+
// Format socket address for display (handles IPv6 addresses)
90+
function formatSocketAddress(host: string, port: string): string {
91+
// Check if this is an IPv6 address by looking for colons
92+
if (host.includes(':')) {
93+
// IPv6 address - check if it already has brackets
94+
if (!host.startsWith('[')) {
95+
return `[${host}]:${port}`
96+
}
97+
// Already has brackets, just append port
98+
return `${host}:${port}`
99+
}
100+
// IPv4 address or hostname
101+
return `${host}:${port}`
102+
}
103+
89104
// Get target display text
90105
function getTargetText(target: ProxyTarget): string {
106+
const socketAddress = formatSocketAddress(target.host, target.port)
107+
91108
if (!shouldShowMultiNodeDisplay.value) {
92109
// Fallback to single-node display
93110
const result = proxyStore.getAvailabilityResult(target)
94111
if (!result)
95-
return `${target.host}:${target.port}`
112+
return socketAddress
96113

97114
if (result.online) {
98-
return `${target.host}:${target.port} (${result.latency.toFixed(2)}ms)`
115+
return `${socketAddress} (${result.latency.toFixed(2)}ms)`
99116
}
100117
else {
101-
return `${target.host}:${target.port}`
118+
return socketAddress
102119
}
103120
}
104121

@@ -107,7 +124,7 @@ export function useUpstreamStatus(envGroupId?: Ref<number | undefined>) {
107124
const totalNodes = calculateTotalNodes(group, testType)
108125
const onlineCount = calculateOnlineCount(target, group, testType)
109126

110-
return `${target.host}:${target.port} (${onlineCount}/${totalNodes})`
127+
return `${socketAddress} (${onlineCount}/${totalNodes})`
111128
}
112129

113130
// Get target tooltip title

app/src/pinia/moudule/proxyAvailability.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,23 @@ export const useProxyAvailabilityStore = defineStore('proxyAvailability', () =>
3636

3737
const nodeStore = useNodeAvailabilityStore()
3838

39+
// Format socket address for target key (handles IPv6 addresses)
40+
function formatSocketAddress(host: string, port: string): string {
41+
// Check if this is an IPv6 address by looking for colons
42+
if (host.includes(':')) {
43+
// IPv6 address - check if it already has brackets
44+
if (!host.startsWith('[')) {
45+
return `[${host}]:${port}`
46+
}
47+
// Already has brackets, just append port
48+
return `${host}:${port}`
49+
}
50+
// IPv4 address or hostname
51+
return `${host}:${port}`
52+
}
53+
3954
function getTargetKey(target: ProxyTarget): string {
40-
return `${target.host}:${target.port}`
55+
return formatSocketAddress(target.host, target.port)
4156
}
4257

4358
// Initialize availability data from HTTP API

0 commit comments

Comments
 (0)