Skip to content

Commit 5bbe034

Browse files
karchermWebFreak001
authored andcommitted
Support unix-based X11 server connections as well as TCP-based ones
Typically, on unix systems, local X11 is connected through the socket `/tmp/.X11-unix/X0`, as indicated by the missing host name part in `DISPLAY=:0` or `DISPLAY=:0.0`. WSLg (the X11 implementation provided with WSL in Microsoft Windows) does not listen on the TCP socket localhost:6000, but on the Unix socket only. So this commit enables SSH X11 forwarding to connect to the unix domain socket if the X server host name is set to the empty string.
1 parent eb9f5e4 commit 5bbe034

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@
281281
"number",
282282
"string"
283283
],
284-
"description": "Port to redirect X11 data to (by default port = display + 6000)",
284+
"description": "TCP port to redirect X11 data to (by default port = display + 6000); raw display number for unix domain connection",
285285
"default": 6000
286286
},
287287
"x11host": {
288288
"type": "string",
289-
"description": "Hostname/ip to redirect X11 data to",
289+
"description": "Hostname/ip to redirect X11 data to; empty string for a unix domain connection",
290290
"default": "localhost"
291291
},
292292
"remotex11screen": {
@@ -455,12 +455,12 @@
455455
"number",
456456
"string"
457457
],
458-
"description": "Port to redirect X11 data to (by default port = display + 6000)",
458+
"description": "TCP port to redirect X11 data to (by default port = display + 6000); raw display number for unix domain connection",
459459
"default": 6000
460460
},
461461
"x11host": {
462462
"type": "string",
463-
"description": "Hostname/ip to redirect X11 data to",
463+
"description": "Hostname/ip to redirect X11 data to; empty string for a unix domain connection",
464464
"default": "localhost"
465465
},
466466
"remotex11screen": {
@@ -755,15 +755,15 @@
755755
},
756756
"x11host": {
757757
"type": "string",
758-
"description": "Hostname/ip to redirect X11 data to",
758+
"description": "Hostname/ip to redirect X11 data to; empty string for a unix domain connection",
759759
"default": "localhost"
760760
},
761761
"x11port": {
762762
"type": [
763763
"number",
764764
"string"
765765
],
766-
"description": "Port to redirect X11 data to (by default port = display + 6000)",
766+
"description": "TCP port to redirect X11 data to (by default port = display + 6000); raw display number for unix domain connection",
767767
"default": 6000
768768
},
769769
"remotex11screen": {

src/backend/mi2/mi2.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ export class MI2 extends EventEmitter implements IBackend {
155155
const xclientsock = accept();
156156
xclientsock.pipe(xserversock).pipe(xclientsock);
157157
});
158-
xserversock.connect(args.x11port, args.x11host);
158+
if (args.x11host !== "")
159+
xserversock.connect(args.x11port, args.x11host);
160+
else
161+
xserversock.connect(`/tmp/.X11-unix/X${args.x11port}`);
159162
});
160163
}
161164

0 commit comments

Comments
 (0)