mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-07-08 11:30:42 +00:00
rdp fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.rdp;
|
||||
|
||||
import io.xpipe.app.core.AppInstallation;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
import io.xpipe.app.process.CommandSupport;
|
||||
@@ -12,6 +13,8 @@ import lombok.Builder;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@JsonTypeName("freeRdp")
|
||||
@Value
|
||||
@Jacksonized
|
||||
@@ -97,22 +100,34 @@ public class FreeRdpClient implements ExternalRdpClient {
|
||||
.add("-themes")
|
||||
.add("/size:100%");
|
||||
|
||||
if (configuration.getPassword() != null) {
|
||||
b.add(argument("/p", configuration.getPassword().getSecretValue()));
|
||||
}
|
||||
|
||||
var gateway = configuration.getGateway();
|
||||
if (gateway != null) {
|
||||
b.add("/g").addQuoted(gateway.getHost());
|
||||
if (gateway.getUsername() != null) {
|
||||
b.add("/gu").addQuoted(gateway.getUsername());
|
||||
}
|
||||
if (gateway.getPassword() != null) {
|
||||
var escapedPw = gateway.getPassword().getSecretValue().replaceAll("'", "\\\\'");
|
||||
b.add("/gp:'" + escapedPw + "'");
|
||||
if (exec.isV3()) {
|
||||
// Horrible quoting rules: https://github.com/FreeRDP/FreeRDP/issues/11396
|
||||
String s = "g:" + gateway.getHost();
|
||||
if (gateway.getUsername() != null) {
|
||||
s += "," + gatewayArgument("u", gateway.getUsername());
|
||||
}
|
||||
if (gateway.getPassword() != null) {
|
||||
s += "," + gatewayArgument("p", gateway.getPassword().getSecretValue());
|
||||
}
|
||||
b.add(gatewayArgument("/gateway", s));
|
||||
} else {
|
||||
b.add(argument("/g", gateway.getHost()));
|
||||
if (gateway.getUsername() != null) {
|
||||
b.add(argument("/gu", gateway.getUsername()));
|
||||
}
|
||||
if (gateway.getPassword() != null) {
|
||||
b.add(argument("/gp", gateway.getPassword().getSecretValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration.getPassword() != null) {
|
||||
var escapedPw = configuration.getPassword().getSecretValue().replaceAll("'", "\\\\'");
|
||||
b.add("/p:'" + escapedPw + "'");
|
||||
}
|
||||
b.fixedEnvironment("FREERDP_ASKPASS", AppInstallation.ofCurrent().getCliExecutablePath().toString());
|
||||
|
||||
try (var sc = LocalShell.getShell().start()) {
|
||||
var cmd = sc.getShellDialect().launchAsync(b, true);
|
||||
@@ -120,6 +135,16 @@ public class FreeRdpClient implements ExternalRdpClient {
|
||||
}
|
||||
}
|
||||
|
||||
private String gatewayArgument(String key, String value) {
|
||||
var escaped = value.replaceAll("\"", "\\\\\"");
|
||||
return "\"" + key + ":" + escaped + "\"";
|
||||
}
|
||||
|
||||
private String argument(String key, String value) {
|
||||
var escaped = value.replaceAll("'", "\\\\'");
|
||||
return key + ":'" + escaped + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPasswordPassing(RdpLaunchConfig config) {
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class RdpLaunchConfig {
|
||||
return Optional.ofNullable(domain);
|
||||
}
|
||||
|
||||
public String getUserWithoutDomain() {
|
||||
public String getUsernameWithoutDomain() {
|
||||
if (username.contains("\\")) {
|
||||
return username.split("\\\\")[1];
|
||||
} else {
|
||||
|
||||
@@ -28,17 +28,14 @@ public class RemminaRdpClient implements ExternalApplicationType.LinuxApplicatio
|
||||
}
|
||||
}
|
||||
|
||||
var encrypted = RemminaHelper.encryptPassword(configuration.getPassword());
|
||||
if (encrypted.isPresent()) {
|
||||
var file = RemminaHelper.writeRemminaRdpConfigFile(configuration);
|
||||
launch(CommandBuilder.of().add("-c").addFile(file.toString()));
|
||||
return;
|
||||
}
|
||||
var file = RemminaHelper.writeRemminaRdpConfigFile(configuration);
|
||||
LocalFileTracker.deleteOnExit(file);
|
||||
launch(CommandBuilder.of().add("-c").addFile(file.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPasswordPassing(RdpLaunchConfig config) {
|
||||
return config.isRemoteApp();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,10 +95,10 @@ public class RemminaHelper {
|
||||
window_maximize=%s%s
|
||||
""".formatted(
|
||||
configuration.getTitle(),
|
||||
configuration.getUsername(),
|
||||
configuration.getUsernameWithoutDomain(),
|
||||
configuration.getDomain().orElse(""),
|
||||
configuration.getHost(),
|
||||
configuration.getPassword() != null ? encryptPassword(configuration.getPassword()) : "",
|
||||
configuration.getPassword() != null ? encryptPassword(configuration.getPassword()).orElse("") : "",
|
||||
w,
|
||||
h,
|
||||
maximize,
|
||||
|
||||
Reference in New Issue
Block a user