ssh bridge fixes

This commit is contained in:
crschnick 2024-08-16 10:24:45 +00:00
parent 749f3e706e
commit 6a946dbc5a
2 changed files with 6 additions and 14 deletions

View file

@ -1,27 +1,19 @@
package io.xpipe.app.beacon.impl; package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.TerminalLauncherManager; import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.SshLaunchExchange; import io.xpipe.beacon.api.SshLaunchExchange;
import io.xpipe.core.process.ProcessControlProvider; import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.process.TerminalInitScriptConfig; import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.store.StorePath;
import java.util.UUID;
public class SshLaunchExchangeImpl extends SshLaunchExchange { public class SshLaunchExchangeImpl extends SshLaunchExchange {
@Override @Override
public Object handle(HttpExchange exchange, Request msg) throws Exception { public Object handle(HttpExchange exchange, Request msg) throws Exception {
if (msg.getStorePath() != null && !msg.getStorePath().contains("SSH_ORIGINAL_COMMAND")) { var usedDialect = ShellDialects.ALL.stream().filter(dialect -> dialect.getExecutableName().equalsIgnoreCase(msg.getArguments())).findFirst();
var storePath = StorePath.create(msg.getStorePath()); if (msg.getArguments() != null && usedDialect.isEmpty() && !msg.getArguments().contains("SSH_ORIGINAL_COMMAND")) {
var found = DataStorage.get().getStoreEntries().stream().filter(entry -> DataStorage.get().getStorePath(entry).equals(storePath)).findFirst(); throw new BeaconClientException("Unexpected argument: " + msg.getArguments());
if (found.isPresent() && found.get().getStore() instanceof ShellStore shellStore) {
TerminalLauncherManager.submitAsync(UUID.randomUUID(), shellStore.control(),
TerminalInitScriptConfig.ofName(DataStorage.get().getStoreEntryDisplayName(found.get())),null);
}
} }
var r = TerminalLauncherManager.waitForNextLaunch(); var r = TerminalLauncherManager.waitForNextLaunch();

View file

@ -19,7 +19,7 @@ public class SshLaunchExchange extends BeaconInterface<SshLaunchExchange.Request
@Builder @Builder
@Value @Value
public static class Request { public static class Request {
String storePath; String arguments;
} }
@Jacksonized @Jacksonized