Rotate service URLs [stage] [arm]

This commit is contained in:
crschnick
2025-09-09 01:08:23 +00:00
parent 348bef0418
commit efa4e981da
4 changed files with 41 additions and 10 deletions
+1
View File
@@ -1,2 +1,3 @@
- Fix some types connection entries being moved to default category after their configuration was edited
- Fix bitwarden login issues when using custom server
- Rotate service URLs to avoid browser cache issues when running multiple services on localhost
@@ -40,15 +40,7 @@ public abstract class AbstractServiceStore implements SingletonSessionStore<Netw
}
public String getOpenTargetUrl() {
var s = getSession();
if (s == null) {
var host = getHost().getStore().getTunnelHostName() != null
? getHost().getStore().getTunnelHostName()
: "localhost";
return host + ":" + remotePort;
}
return "localhost:" + s.getLocalPort();
return ServiceAddressRotation.getRotatedAddress(this);
}
public boolean requiresTunnel() {
@@ -0,0 +1,38 @@
package io.xpipe.ext.base.service;
import java.util.HashMap;
import java.util.Map;
public class ServiceAddressRotation {
private static final Map<String, String> replacedUrls = new HashMap<>();
private static int counter = 0;
private static final String[] aliases = new String[]{ "localhost", "127.0.0.1" };
private static String getRotatedLocalhost(String url) {
if (!url.startsWith("localhost")) {
return url;
}
if (replacedUrls.containsKey(url)) {
return replacedUrls.get(url);
}
var alias = aliases[counter++ % aliases.length];
var replaced = url.replace("localhost", alias);
replacedUrls.put(url, replaced);
return replaced;
}
public static String getRotatedAddress(AbstractServiceStore serviceStore) {
var s = serviceStore.getSession();
if (s == null) {
var host = serviceStore.getHost().getStore().getTunnelHostName() != null
? serviceStore.getHost().getStore().getTunnelHostName()
: "localhost";
return getRotatedLocalhost(host + ":" + serviceStore.getRemotePort());
}
return getRotatedLocalhost("localhost:" + s.getLocalPort());
}
}
+1 -1
View File
@@ -1 +1 @@
18.6-1
18.6-2