Skip to content

net: XDMCP reverse-proxy ALG for remote X login into the guest (NAT mode)#43

Open
danifunker wants to merge 2 commits into
techomancer:mainfrom
danifunker:add-xdmcp
Open

net: XDMCP reverse-proxy ALG for remote X login into the guest (NAT mode)#43
danifunker wants to merge 2 commits into
techomancer:mainfrom
danifunker:add-xdmcp

Conversation

@danifunker

Copy link
Copy Markdown
Contributor

What

Adds an XDMCP (X Display Manager Control Protocol, UDP/177) application-layer
gateway so a modern X server can display the guest's IRIX login screen and desktop
by querying its xdm through the software NAT — the XDMCP analog of the existing
FTP PASV ALG. Verified against IRIX 5.3 and 6.5 (both speak XDMCP 1.0).

Applies to NAT mode. In PCAP bridged mode the guest is a real L2 host, so no
proxy is needed.

Why

In NAT mode the guest isn't directly addressable, and the XDMCP Request carries
the X server's connection-addresses (where the session should connect back) —
not reachable as-is from behind the NAT (e.g. 127.0.0.1 for an X server on the
IRIS host).

How

  • src/xdmcp.rs — pure, unit-tested XDMCP-1.0 parser + rewrite_request_ipv4():
    rewrites the Request's IPv4 connection-addresses to the gateway
    (length-preserving — IPv4→IPv4, so only the UDP checksum changes) and reports
    the display number + the X server's original address(es).
  • net.rs — on a UDP forward to guest:177, rewrite the Request and record
    display → X-server in a new xdmcp_sessions table. nfs_remap_dst /
    nfs_unmap_src consult it so the guest's X11 session to gateway:(6000+display)
    is relayed to the real X server: a same-host server rides the existing
    gateway→loopback DNAT, a LAN server uses the recorded address. Cleared on reset.
  • iris-gui — a Port-forwards preset: "XDMCP (host 11177 → guest 177, UDP)".
  • docs/xdmcp.md — setup (forward, guest xdm, the 177→11177 redirect, X
    server TCP listening).

Testing

  • cargo test green (incl. 4 new xdmcp unit tests).
  • End-to-end: NAT mode + Xephyr :1 -query <host> -ac -listen tcp via a socat
    177→11177 bridge → the IRIX xdm greeter displayed and login to the full
    desktop worked.

Notes

  • External port defaults to 11177 (unprivileged, so IRIS needs no elevation).
    Stock X servers hardcode UDP 177, so a one-time 177→11177 redirect (pf/iptables)
    is documented in docs/xdmcp.md.
  • Auth: MIT-MAGIC-COOKIE-1 / none are supported (address-independent).
    XDM-AUTHORIZATION-1 cryptographically binds the addresses, so the rewrite
    would break it — it's detected and left unrewritten.
  • IPv4 only.

🤖 Generated with Claude Code

danifunker and others added 2 commits June 21, 2026 17:13
… core)

New src/xdmcp.rs: the pure, unit-tested core of the XDMCP reverse-proxy ALG.
rewrite_request_ipv4() swaps the IPv4 connection-addresses in an XDMCP Request
to the NAT gateway (length-preserving) and reports the display number + the X
server's real address, so net.rs can wire up the X11 session proxy. Mirrors the
FTP PASV ALG pattern. 4 unit tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- net.rs: on the XDMCP UDP forward (-> guest:177), rewrite the Request's
  connection-addresses to the gateway and record display->X-server in a new
  xdmcp_sessions table (poll_udp_fwd_listeners).
- net.rs: nfs_remap_dst/nfs_unmap_src consult that table so the guest's X11
  session to gateway:(6000+display) is relayed to the real X server -- localhost
  rides the existing gateway->loopback DNAT; a LAN X server uses the recorded
  address. Cleared on machine reset.
- iris-gui: '+ Add forward' preset 'XDMCP (host 11177 to guest 177, UDP)',
  binds all interfaces.
- docs/xdmcp.md: setup (forward, guest xdm, 177->11177 redirect, X server TCP).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant