@@ -24,16 +24,18 @@ import (
2424
2525// StartWithConn hands an independent dup of conn's fd to the bridge.
2626// For TLS-wrapped or otherwise non-fd-backed conns, use StartWithReadWriter.
27- func StartWithConn (conn net.Conn , targetHost string , targetPort uint16 , username , password string ) (* Bridge , error ) {
27+ // `domain` is empty for local accounts; set to the AD domain name for
28+ // domain-joined NTLM CredSSP.
29+ func StartWithConn (conn net.Conn , targetHost string , targetPort uint16 , username , password , domain string ) (* Bridge , error ) {
2830 dupFd , err := dupConnFD (conn )
2931 if err != nil {
3032 return nil , fmt .Errorf ("rdp bridge: dup client fd: %w" , err )
3133 }
32- return startWithDupedFD (dupFd , targetHost , targetPort , username , password )
34+ return startWithDupedFD (dupFd , targetHost , targetPort , username , password , domain )
3335}
3436
3537// Ownership of dupFd transfers to Rust on success; we close it on failure.
36- func startWithDupedFD (dupFd int , targetHost string , targetPort uint16 , username , password string ) (* Bridge , error ) {
38+ func startWithDupedFD (dupFd int , targetHost string , targetPort uint16 , username , password , domain string ) (* Bridge , error ) {
3739 success := false
3840 defer func () {
3941 if ! success {
@@ -48,13 +50,21 @@ func startWithDupedFD(dupFd int, targetHost string, targetPort uint16, username,
4850 cPass := C .CString (password )
4951 defer C .free (unsafe .Pointer (cPass ))
5052
53+ // Empty domain -> NULL pointer; bridge treats both the same way.
54+ var cDomain * C.char
55+ if domain != "" {
56+ cDomain = C .CString (domain )
57+ defer C .free (unsafe .Pointer (cDomain ))
58+ }
59+
5160 var handle C.uint64_t
5261 rc := C .rdp_bridge_start_unix_fd (
5362 C .int (dupFd ),
5463 cHost ,
5564 C .uint16_t (targetPort ),
5665 cUser ,
5766 cPass ,
67+ cDomain ,
5868 & handle ,
5969 )
6070 if rc != C .RDP_BRIDGE_OK {
@@ -77,7 +87,7 @@ func startWithDupedFD(dupFd int, targetHost string, targetPort uint16, username,
7787//
7888// Cost: two extra in-process copies and a loopback round-trip per byte.
7989// Negligible vs. the TLS + CredSSP work on either side.
80- func StartWithReadWriter (rw io.ReadWriter , targetHost string , targetPort uint16 , username , password string ) (* Bridge , error ) {
90+ func StartWithReadWriter (rw io.ReadWriter , targetHost string , targetPort uint16 , username , password , domain string ) (* Bridge , error ) {
8191 listener , err := net .Listen ("tcp" , "127.0.0.1:0" )
8292 if err != nil {
8393 return nil , fmt .Errorf ("rdp bridge: loopback listen: %w" , err )
@@ -112,7 +122,7 @@ func StartWithReadWriter(rw io.ReadWriter, targetHost string, targetPort uint16,
112122 return nil , fmt .Errorf ("rdp bridge: dup accepted fd: %w" , err )
113123 }
114124
115- bridge , err := startWithDupedFD (dupFd , targetHost , targetPort , username , password )
125+ bridge , err := startWithDupedFD (dupFd , targetHost , targetPort , username , password , domain )
116126 if err != nil {
117127 _ = peer .Close ()
118128 return nil , err
@@ -168,6 +178,7 @@ func (p *RDPProxy) HandleConnection(ctx context.Context, clientConn net.Conn) er
168178 p .config .TargetPort ,
169179 p .config .InjectUsername ,
170180 p .config .InjectPassword ,
181+ p .config .InjectDomain ,
171182 )
172183 if err != nil {
173184 return fmt .Errorf ("rdp proxy: start bridge: %w" , err )
0 commit comments