This commit is contained in:
crschnick
2024-04-07 11:11:16 +00:00
parent dfcb90bd16
commit 3d64443ed5
15 changed files with 73 additions and 82 deletions
@@ -92,9 +92,5 @@ public interface BrowserAction {
.toList());
}
@Override
public boolean prioritizeLoading() {
return false;
}
}
}
@@ -1,14 +1,9 @@
package io.xpipe.app.core;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import io.xpipe.app.exchange.MessageExchangeImpls;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.ext.ExtensionException;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.util.JacksonMapper;
import io.xpipe.core.util.ModuleHelper;
import io.xpipe.core.util.ModuleLayerLoader;
import io.xpipe.core.util.XPipeInstallation;
@@ -53,24 +48,10 @@ public class AppExtensionManager {
if (load) {
try {
ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, true, t -> {
ErrorEvent.fromThrowable(t).handle();
});
ProcessControlProvider.init(INSTANCE.extendedLayer);
TrackEvent.info("Loading extension providers ...");
DataStoreProviders.init(INSTANCE.extendedLayer);
for (DataStoreProvider p : DataStoreProviders.getAll()) {
TrackEvent.trace("Loaded data store provider " + p.getId());
JacksonMapper.configure(objectMapper -> {
for (Class<?> storeClass : p.getStoreClasses()) {
objectMapper.registerSubtypes(new NamedType(storeClass));
}
});
}
ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, false, t -> {
ModuleLayerLoader.loadAll(INSTANCE.extendedLayer, t -> {
ErrorEvent.fromThrowable(t).handle();
});
MessageExchangeImpls.loadAll();
} catch (Throwable t) {
throw new ExtensionException(
"Service provider initialization failed. Is the installation data corrupt?", t);
@@ -48,6 +48,10 @@ public class AppI18n {
private final Property<LoadedTranslations> currentLanguage = new SimpleObjectProperty<>();
public static void init() throws Exception {
if (INSTANCE != null) {
return;
}
INSTANCE = new AppI18n();
INSTANCE.load();
}
@@ -3,6 +3,7 @@ package io.xpipe.app.exchange;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import io.xpipe.beacon.exchange.MessageExchanges;
import io.xpipe.core.util.ModuleLayerLoader;
import java.util.List;
import java.util.Optional;
@@ -11,28 +12,33 @@ import java.util.stream.Collectors;
public class MessageExchangeImpls {
public static class Loader implements ModuleLayerLoader {
@Override
public void init(ModuleLayer layer) {
ALL = ServiceLoader.load(layer, MessageExchangeImpl.class).stream()
.map(s -> {
// TrackEvent.trace("init", "Loaded exchange implementation " + ex.getId());
return (MessageExchangeImpl<?, ?>) s.get();
})
.collect(Collectors.toList());
ALL.forEach(messageExchange -> {
if (MessageExchanges.byId(messageExchange.getId()).isEmpty()) {
throw new AssertionError("Missing base exchange: " + messageExchange.getId());
}
});
MessageExchanges.getAll().forEach(messageExchange -> {
if (MessageExchangeImpls.byId(messageExchange.getId()).isEmpty()) {
throw new AssertionError("Missing exchange implementation: " + messageExchange.getId());
}
});
}
}
private static List<MessageExchangeImpl<?, ?>> ALL;
public static void loadAll() {
ALL = ServiceLoader.load(MessageExchangeImpl.class).stream()
.map(s -> {
// TrackEvent.trace("init", "Loaded exchange implementation " + ex.getId());
return (MessageExchangeImpl<?, ?>) s.get();
})
.collect(Collectors.toList());
ALL.forEach(messageExchange -> {
if (MessageExchanges.byId(messageExchange.getId()).isEmpty()) {
throw new AssertionError("Missing base exchange: " + messageExchange.getId());
}
});
MessageExchanges.getAll().forEach(messageExchange -> {
if (MessageExchangeImpls.byId(messageExchange.getId()).isEmpty()) {
throw new AssertionError("Missing exchange implementation: " + messageExchange.getId());
}
});
}
@SuppressWarnings("unchecked")
public static <RQ extends RequestMessage, RS extends ResponseMessage> Optional<MessageExchangeImpl<RQ, RS>> byId(
@@ -144,9 +144,5 @@ public interface ActionProvider {
.toList());
}
@Override
public boolean prioritizeLoading() {
return false;
}
}
}
@@ -1,7 +1,11 @@
package io.xpipe.app.ext;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.util.JacksonMapper;
import io.xpipe.core.util.ModuleLayerLoader;
import java.util.List;
import java.util.Optional;
@@ -10,13 +14,12 @@ import java.util.stream.Collectors;
public class DataStoreProviders {
private static List<DataStoreProvider> ALL;
public static class Loader implements ModuleLayerLoader {
public static void init(ModuleLayer layer) {
if (ALL == null) {
ALL = ServiceLoader.load(layer, DataStoreProvider.class).stream()
.map(ServiceLoader.Provider::get)
.collect(Collectors.toList());
@Override
public void init(ModuleLayer layer) {
TrackEvent.info("Loading extension providers ...");
ALL = ServiceLoader.load(layer, DataStoreProvider.class).stream().map(ServiceLoader.Provider::get).collect(Collectors.toList());
ALL.removeIf(p -> {
try {
if (!p.init()) {
@@ -30,9 +33,20 @@ public class DataStoreProviders {
return true;
}
});
for (DataStoreProvider p : getAll()) {
TrackEvent.trace("Loaded data store provider " + p.getId());
JacksonMapper.configure(objectMapper -> {
for (Class<?> storeClass : p.getStoreClasses()) {
objectMapper.registerSubtypes(new NamedType(storeClass));
}
});
}
}
}
private static List<DataStoreProvider> ALL;
public static void postInit(ModuleLayer layer) {
ALL.forEach(p -> {
try {
@@ -35,9 +35,5 @@ public abstract class PrefsProvider {
.collect(Collectors.toList());
}
@Override
public boolean prioritizeLoading() {
return false;
}
}
}
@@ -63,9 +63,5 @@ public abstract class ScanProvider {
.collect(Collectors.toList());
}
@Override
public boolean prioritizeLoading() {
return false;
}
}
}
@@ -42,9 +42,5 @@ public abstract class LicenseProvider {
.orElseThrow(() -> ExtensionException.corrupt("Missing license provider"));
}
@Override
public boolean prioritizeLoading() {
return true;
}
}
}
+2 -4
View File
@@ -3,10 +3,7 @@ import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.core.AppLogs;
import io.xpipe.app.exchange.*;
import io.xpipe.app.exchange.cli.*;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.PrefsProvider;
import io.xpipe.app.ext.ScanProvider;
import io.xpipe.app.ext.*;
import io.xpipe.app.issue.EventHandler;
import io.xpipe.app.issue.EventHandlerImpl;
import io.xpipe.app.storage.DataStateProviderImpl;
@@ -120,6 +117,7 @@ open module io.xpipe.app {
provides Module with
StorageJacksonModule;
provides ModuleLayerLoader with
MessageExchangeImpls.Loader, DataStoreProviders.Loader,
ActionProvider.Loader,
PrefsProvider.Loader,
BrowserAction.Loader,
@@ -78,10 +78,5 @@ public class ShellDialects {
RBASH = byId("rbash");
OVH_BASTION = byId("ovhBastion");
}
@Override
public boolean prioritizeLoading() {
return true;
}
}
}
@@ -6,14 +6,10 @@ import java.util.function.Consumer;
public interface ModuleLayerLoader {
static void loadAll(
ModuleLayer layer, boolean prioritization, Consumer<Throwable> errorHandler) {
ModuleLayer layer, Consumer<Throwable> errorHandler) {
ServiceLoader.load(layer, ModuleLayerLoader.class).stream().forEach(moduleLayerLoaderProvider -> {
var instance = moduleLayerLoaderProvider.get();
try {
if (instance.prioritizeLoading() != prioritization) {
return;
}
instance.init(layer);
} catch (Throwable t) {
errorHandler.accept(t);
@@ -21,7 +17,8 @@ public interface ModuleLayerLoader {
});
}
void init(ModuleLayer layer);
default void init(ModuleLayer layer) {}
default void reset() {}
boolean prioritizeLoading();
}
@@ -204,6 +204,8 @@ commandShellTypeDescription=The shell to use for this command
ssh.passwordDescription=The optional password to use when authenticating
keyAuthentication=Key-based authentication
keyAuthenticationDescription=The authentication method to use if key-based authentication is required.
dontInteractWithSystem=Don't interact with system (Pro)
dontInteractWithSystemDescription=Don't try to identify shell and operating system type
customAgent=Custom agent
identityAgent=Identity agent
ssh.proxyDescription=The optional proxy host to use when establishing the SSH connection. Must have an ssh client installed.
+9
View File
@@ -0,0 +1,9 @@
## X11 Forwarding
When this option is enabled, the SSH connection will be started with X11 forwarding set up. On Linux, this will usually work out of the box and does not require any setup. On macOS, you need an X11 server like [XQuartz](https://www.xquartz.org/) to be running on your local machine.
### X11 on Windows
XPipe allows you to use the WSL2 X11 capabilities for your SSH connection. The only thing you need for this is a [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) distribution installed on your local system. XPipe it will automatically choose a compatible installed distribution if possible, but you can also use another one in the settings menu.
This means that you don't need to install a separate X11 server on Windows. However, if you are using one anyway, XPipe will detect that and use the currently running X11 server.
+5
View File
@@ -0,0 +1,5 @@
## System interaction
XPipe tries to detect what kind of shell it logged into to verify that everything worked correctly and to display system information. That works for normal command shells like bash, but fails for non-standard and custom login shells for many embedded systems. You have to disable this behavior in order for connections to these systems to succeed.
When this interaction is disabled, it will not attempt to identify any system information. This will prevent the system to be used in the file browser or as a proxy/gateway system for other connections. XPipe will then essentially just act as a launcher for the connection.