mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-12 20:40:59 +00:00
Small fixes for proxies
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package io.xpipe.core.util;
|
||||
|
||||
import io.xpipe.core.process.ShellProcessControl;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public abstract class ProxyManagerProvider {
|
||||
|
||||
private static ProxyManagerProvider INSTANCE;
|
||||
|
||||
public static ProxyManagerProvider get() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = ServiceLoader.load(ModuleLayer.boot(), ProxyManagerProvider.class)
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public abstract Optional<String> checkCompatibility(ShellProcessControl pc) throws Exception;
|
||||
|
||||
public abstract boolean setup(ShellProcessControl pc) throws Exception;
|
||||
}
|
||||
@@ -22,6 +22,8 @@ public abstract class ProxyProvider {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public abstract <T> T downstreamTransform(T object, ShellStore proxy);
|
||||
|
||||
public abstract ShellStore getProxy(Object base);
|
||||
|
||||
public abstract boolean isRemote(Object base);
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
public class XPipeInstallation {
|
||||
|
||||
public static String getInstallationBasePathForCLI(ShellProcessControl p, String cliExecutable) throws Exception {
|
||||
var defaultInstallation = getDefaultInstallationBasePath(p);
|
||||
var defaultInstallation = getDefaultInstallationBasePath(p, true);
|
||||
if (p.getOsType().equals(OsType.LINUX) && cliExecutable.equals("/usr/bin/xpipe")) {
|
||||
return defaultInstallation;
|
||||
}
|
||||
@@ -32,18 +32,6 @@ public class XPipeInstallation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsCompatibleDefaultInstallation(ShellProcessControl p, String version) throws Exception {
|
||||
var defaultBase = getDefaultInstallationBasePath(p);
|
||||
var executable = getInstallationExecutable(p, defaultBase);
|
||||
if (!p.executeBooleanSimpleCommand(p.getShellType().createFileExistsCommand(executable))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try (CommandProcessControl c = p.command(List.of(executable, "version")).start()) {
|
||||
return c.readOrThrow().equals(version);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getInstallationExecutable(ShellProcessControl p, String installation) throws Exception {
|
||||
var executable = getDaemonExecutablePath(p.getOsType());
|
||||
var file = FileNames.join(installation, executable);
|
||||
@@ -61,14 +49,16 @@ public class XPipeInstallation {
|
||||
|
||||
public static String getDefaultInstallationBasePath() throws Exception {
|
||||
try (ShellProcessControl pc = new LocalStore().create().start()) {
|
||||
return getDefaultInstallationBasePath(pc);
|
||||
return getDefaultInstallationBasePath(pc, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDefaultInstallationBasePath(ShellProcessControl p) throws Exception {
|
||||
var customHome = p.executeStringSimpleCommand(p.getShellType().getPrintVariableCommand("XPIPE_HOME"));
|
||||
if (!customHome.isEmpty()) {
|
||||
return customHome;
|
||||
public static String getDefaultInstallationBasePath(ShellProcessControl p, boolean acceptPortable) throws Exception {
|
||||
if (acceptPortable) {
|
||||
var customHome = p.executeStringSimpleCommand(p.getShellType().getPrintVariableCommand("XPIPE_HOME"));
|
||||
if (!customHome.isEmpty()) {
|
||||
return customHome;
|
||||
}
|
||||
}
|
||||
|
||||
String path = null;
|
||||
|
||||
@@ -26,6 +26,7 @@ open module io.xpipe.core {
|
||||
uses io.xpipe.core.source.WriteMode;
|
||||
uses LocalProcessControlProvider;
|
||||
uses io.xpipe.core.util.ProxyProvider;
|
||||
uses io.xpipe.core.util.ProxyManagerProvider;
|
||||
|
||||
provides WriteMode with WriteMode.Replace, WriteMode.Append, WriteMode.Prepend;
|
||||
provides com.fasterxml.jackson.databind.Module with
|
||||
|
||||
Reference in New Issue
Block a user