Skip to content

Commit 59bf40e

Browse files
committed
feat: Windows support
Depends on https://github.com/jstarks/npiperelay
1 parent ea840ef commit 59bf40e

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

lib/remote_connection.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,35 @@ class RemoteConnection {
6969

7070
printOut.add("connection successful.");
7171

72-
final session = await client.execute("which socat");
72+
final windows = client.remoteVersion?.contains("Windows") ?? false;
73+
74+
late final SSHSession session;
75+
late final String util;
76+
77+
if (windows) {
78+
printOut.add("Windows detected.");
79+
util = "npiperelay";
80+
session = await client.execute("where.exe $util.exe");
81+
} else {
82+
util = "socat";
83+
session = await client.execute("which $util");
84+
}
7385
session.stdin.close();
7486

7587
await session.stdout.listen((bytes) {
7688
for (final line in utf8.decode(bytes).trim().split("\n")) {
77-
printOut.add("which: $line");
89+
printOut.add("$util found: $line");
7890
}
7991
}).asFuture();
8092

8193
await session.done;
8294

8395
if (session.exitCode == 0) {
84-
printOut.add("`socat` found.");
96+
printOut.add("`$util` found.");
8597
printOut.add("test successful.");
8698
return true;
8799
} else {
88-
printOut.add("`socat` not found.");
100+
printOut.add("`$util` not found.");
89101
printOut.add("test failed.");
90102
return false;
91103
}
@@ -101,7 +113,8 @@ class RemoteConnection {
101113

102114
await client.authenticated;
103115

104-
final session = await client.execute("socat - $socketPath");
116+
final session = await client.execute(
117+
"${client.remoteVersion?.contains("Windows") ?? false ? "npiperelay.exe" : "socat -"} $socketPath");
105118

106119
// stdin and stdout are newline-separated JSON objects
107120
return MpvSocket(

0 commit comments

Comments
 (0)