More polishing

This commit is contained in:
crschnick 2023-08-03 17:20:53 +00:00
parent c554482bb1
commit 56930c07a6
11 changed files with 77 additions and 34 deletions

View file

@ -230,8 +230,10 @@ public class AppSocketServer {
Deobfuscator.deobfuscate(ex);
sendServerErrorResponse(clientSocket, ex);
}
} // Omit it, as this might happen often
catch (Throwable ex) {
} catch (SocketException ex) {
// Omit it, as this might happen often
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
} catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).build().handle();
} finally {
try {

View file

@ -19,6 +19,6 @@ public class LaunchExchangeImpl extends LaunchExchange
return Response.builder().command(List.of(split.toStrings())).build();
}
throw new IllegalArgumentException();
throw new IllegalArgumentException("Not launchable");
}
}

View file

@ -125,7 +125,7 @@ public interface DataStoreProvider {
}
default String queryInvalidInformationString(DataStore store, int length) throws Exception {
return null;
return "Connection failed";
}
default String toSummaryString(DataStore store, int length) {

View file

@ -4,6 +4,7 @@ import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.source.DataStoreId;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.FixedHierarchyStore;
@ -195,6 +196,10 @@ public abstract class DataStorage {
DataStoreEntry current = entry;
while ((current = getParent(current, false).orElse(null)) != null) {
if (new LocalStore().equals(current.getStore())) {
break;
}
names.add(0, current.getName());
}

View file

@ -96,6 +96,8 @@ public class ScanAlert {
btOk.addEventFilter(ActionEvent.ACTION, event -> {
ThreadHelper.runAsync(() -> {
BusyProperty.execute(busy, () -> {
entry.setExpanded(true);
for (var a : selected) {
try {
a.getScanner().run();
@ -104,8 +106,6 @@ public class ScanAlert {
}
}
entry.setExpanded(true);
Platform.runLater(() -> {
alert.setResult(ButtonType.OK);
alert.close();

View file

@ -34,7 +34,7 @@ public class SecretRetrievalStrategyHelper {
var keyProperty =
new SimpleObjectProperty<>(p.getValue() != null ? p.getValue().getKey() : null);
var content = new HorizontalComp(List.<Comp<?>>of(
new TextFieldComp(keyProperty).hgrow(),
new TextFieldComp(keyProperty).apply(struc -> struc.get().setPromptText("Password key")).hgrow(),
new ButtonComp(null, new FontIcon("mdomz-settings"), () -> {
AppPrefs.get().selectCategory(3);
App.getApp().getStage().requestFocus();
@ -54,7 +54,7 @@ public class SecretRetrievalStrategyHelper {
private static OptionsBuilder customCommand(Property<SecretRetrievalStrategy.CustomCommand> p) {
var cmdProperty =
new SimpleObjectProperty<>(p.getValue() != null ? p.getValue().getCommand() : null);
var content = new TextFieldComp(cmdProperty).apply(struc -> struc.get().setPromptText("Password key"));
var content = new TextFieldComp(cmdProperty);
return new OptionsBuilder()
.name("command")
.addComp(content, cmdProperty)
@ -86,7 +86,11 @@ public class SecretRetrievalStrategyHelper {
? 1
: strat instanceof SecretRetrievalStrategy.PasswordManager
? 2
: strat instanceof SecretRetrievalStrategy.CustomCommand ? 3 : strat instanceof SecretRetrievalStrategy.Prompt ? 4 : strat == null ? -1 : 0);
: strat instanceof SecretRetrievalStrategy.CustomCommand
? 3
: strat instanceof SecretRetrievalStrategy.Prompt
? 4
: strat == null ? -1 : 0);
return new OptionsBuilder()
.choice(selected, map)
.bindChoice(

View file

@ -38,6 +38,15 @@ public class CommandBuilder {
return this;
}
public CommandBuilder addIf(boolean b, String... s) {
if (b) {
for (String s1 : s) {
elements.add(new Fixed(s1));
}
}
return this;
}
public CommandBuilder add(String... s) {
for (String s1 : s) {
elements.add(new Fixed(s1));
@ -51,7 +60,24 @@ public class CommandBuilder {
}
public CommandBuilder addQuoted(String s) {
elements.add(new Fixed("\"" + s + "\""));
elements.add(sc -> {
if (sc == null) {
return "\"" + s + "\"";
}
return sc.getShellDialect().quoteArgument(s);
});
return this;
}
public CommandBuilder addSub(CommandBuilder sub) {
elements.add(sc -> {
if (sc == null) {
return sub.buildSimple();
}
return sub.build(sc);
});
return this;
}
@ -75,7 +101,13 @@ public class CommandBuilder {
}
public CommandBuilder addFile(String s) {
elements.add(sc -> sc.getShellDialect().fileArgument(s));
elements.add(sc -> {
if (sc == null) {
return "\"" + s + "\"";
}
return sc.getShellDialect().fileArgument(s);
});
return this;
}
@ -97,6 +129,12 @@ public class CommandBuilder {
}
public String buildSimple() {
return String.join(" ", elements.stream().map(element -> ((Fixed) element).string).toList());
return String.join(" ", elements.stream().map(element -> {
try {
return element.evaluate(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}).toList());
}
}

View file

@ -23,7 +23,7 @@ public interface CommandControl extends ProcessControl {
CommandControl withExceptionConverter(Function<Exception, Exception> converter);
CommandControl withMessageFormatter(Function<String, String> formatter);
CommandControl withErrorFormatter(Function<String, String> formatter);
CommandControl terminalExitMode(TerminalExitMode mode);

View file

@ -29,6 +29,8 @@ public interface ShellDialect {
return true;
}
String getCatchAllVariable();
CommandControl queryVersion(ShellControl shellControl);
CommandControl prepareUserTempDirectory(ShellControl shellControl, String directory);
@ -43,6 +45,8 @@ public interface ShellDialect {
String fileArgument(String s);
String quoteArgument(String s);
String executeWithNoInitFiles(ShellDialect parentDialect, String file);
void prepareDumbTerminalCommands(ShellControl sc) throws Exception;

View file

@ -1,16 +1,12 @@
## Changes in 1.5.0
This is the largest update yet and comes with loads of improvements and changes.
As a side effect, it will also break some existing connections, so be prepared for that.
This is the largest update yet and comes with loads of improvements and changes. There might be some rough edges, but these will be quickly ironed out. So please report any issues you can find!
### Passwords & Password managers
This update comes with a first attempt of supporting the retrieval of passwords from external sources.
Due to the variety of available password managers and formats, I went with the most straightforward approach here which is essentially delegating that task to the CLI of your password manager.
This update comes with a first attempt of supporting the retrieval of passwords from external sources. Due to the variety of available password managers and formats, I went with the most straightforward approach here which is essentially delegating that task to the CLI of your password manager.
Essentially, you're able to specify a command template to retrieve your passwords.
For example, by specifying the command template `mypasswordmgr get $KEY`, you can then choose the password when creating connections by just supplying the key argument.
XPipe will call the command, read the password, and supply it from there.
Essentially, you're able to specify a command template to retrieve your passwords. For example, by specifying the command template `mypasswordmgr get $KEY`, you can then choose the password when creating connections by just supplying the key argument. XPipe will call the command, read the password, and supply it from there.
There's also support to specify an arbitrary command or to dynamically prompt the password on each login.
@ -23,14 +19,11 @@ It is also then possible to refresh and update these detected connections at any
This update brings support for fish as another possible shell type.
Note that there are several limitations with this implementation as fish does
not support an interactive mode in headless environments,
resulting in XPipe having to use a fallback shell for certain operations.
Note that there are several limitations with this implementation as fish does not support an interactive mode in headless environments, resulting in XPipe having to use a fallback shell for certain operations.
### CLI
This update lays the foundation for future advancements in the command-line interface of XPipe.
To start off, it comes with a few new commands to read and write files on remote systems directly from your terminal.
This update lays the foundation for future advancements in the command-line interface of XPipe. To start off, it comes with a few new commands to read and write files on remote systems directly from your terminal.
The workflow is designed as follows:
@ -41,23 +34,19 @@ The workflow is designed as follows:
The id system is flexible, allowing you to only specify as much of the id as is necessary.
An easy example would be the following: Assume that you have a Windows server with an id of `ssh-windows` and want to filter a file there, but you are missing `grep`.
Then you can execute on your local machine: `xpipe drain ssh-windows "C:\myfile.txt" | grep <filter> | xpipe sink ssh-windows "C:\myfile_filtered.txt"`.
An easy example would be the following: Assume that you have a Windows server with an id of `ssh-windows` and want to filter a file there, but you are missing `grep`. Then you can execute on your local machine: `xpipe drain ssh-windows "C:\myfile.txt" | grep <filter> | xpipe sink ssh-windows "C:\myfile_filtered.txt"`.
The XPipe CLI should be put automatically in your path upon installation, you can test that with `xpipe --help`.
Otherwise, you will find it in `<xpipe dir>/cli/bin/xpipe`.
The XPipe CLI should be put automatically in your path upon installation, you can test that with `xpipe --help`. Otherwise, you will find it in `<xpipe dir>/cli/bin/xpipe`.
### Antivirus adjustments
As it turns out, several antivirus programs do not like XPipe and what it is doing with shells.
As a result, some of them quarantine XPipe and even the system shells itself as they get confused of who is making the calls.
As it turns out, several antivirus programs do not like XPipe and what it is doing with shells. As a result, some of them quarantine XPipe and even the system shells itself as they get confused of who is making the calls.
This update aims to reduce any unexpected issues caused by antivirus programs by automatically detecting whether a problematic antivirus is installed and giving the user the chance to prepare for any upcoming issues.
### Cygwin and MSYS2
XPipe can now automatically detect Cygwin and MSYS2 environments on your machine.
This also comes with full support of the feature set for these environments
XPipe can now automatically detect Cygwin and MSYS2 environments on your machine. This also comes with full support of the feature set for these environments
### Misc
@ -69,7 +58,7 @@ This also comes with full support of the feature set for these environments
- Rework os detection logic for passthrough environments like Cygwin and MSYS2
- Fix desktop directory not being determined correctly on Windows when it was moved from the default location
- Fix various checks in file browser not being applied properly and leading to wrong error messages
- Add alternative ways of resolving path in case `realpath` was not available
- Add alternative ways of resolving path in case realpath was not available
- Rework threading in navigation bar in browser to improve responsiveness
- Recheck if prepared update is still the latest one prior to installing it
- Properly use shell script file extension for external editor when creating shell environments

View file

@ -53,6 +53,7 @@ open module io.xpipe.ext.base {
LaunchShortcutAction,
AddStoreAction,
EditStoreAction,
DeleteStoreChildrenAction,
ShareStoreAction,
FileBrowseAction,
BrowseStoreAction,