From c4c10d213000d89430a646897f1dc48a5f47ac89 Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Sat, 12 Jul 2025 19:52:59 +0800 Subject: [PATCH] Fixed #713 - Fixed sorting destination not working bug --- src/web/components/httprp.html | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 1293b07..e5fcc27 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -586,6 +586,28 @@ aliasDomains += `
`; } + //Build the sorting value + let destSortValue = subd.ActiveOrigins.map(o => { + // Check if it's an IP address (with optional port) + let upstreamAddr = o.OriginIpOrDomain; + let subpath = ""; + if (upstreamAddr.indexOf("/") !== -1) { + let parts = upstreamAddr.split("/"); + subpath = parts.slice(1).join("/"); + upstreamAddr = parts[0]; + } + let ipPortRegex = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/; + if (ipPortRegex.test(upstreamAddr)) { + let [ip, port] = upstreamAddr.split(":"); + // Convert IP to hex + let hexIp = ip.split('.').map(x => ('00' + parseInt(x).toString(16)).slice(-2)).join(''); + let hexPort = port ? (port.length < 5 ? port.padStart(5, '0') : port) : ''; + return hexIp + (hexPort ? ':' + hexPort : '') + "/" + subpath; + } + // Otherwise, treat it as a domain name + return upstreamAddr; + }).join(","); + //Build tag list let tagList = renderTagList(subd); let tagListEmpty = (subd.Tags.length == 0); @@ -602,7 +624,7 @@ ${aliasDomains} - +
${upstreams}