[client] Read the relay transport before the sweeper wraps the connection

sweptConn embeds net.Conn, so it does not promote Protocol() from the
concrete relay connection. Asserting transportConn on the wrapper always
failed and left c.transport empty. Read the transport off the dialed
connection first, then wrap it.
This commit is contained in:
Zoltán Papp
2026-08-11 17:55:19 +02:00
parent 072fa8143b
commit e3e5a25605

View File

@@ -427,13 +427,16 @@ func (c *Client) connect(ctx context.Context) (*RelayAddr, error) {
return nil, fmt.Errorf("dial via FQDN: %w", err)
}
}
conn = c.sweeper.WrapConn(conn)
c.relayConn = conn
c.datagramFallbackTriggered.Store(false)
// Read the transport off the concrete connection: the sweeper's wrapper
// embeds net.Conn only, so it does not promote Protocol().
if tc, ok := conn.(transportConn); ok {
c.transport = tc.Protocol()
}
conn = c.sweeper.WrapConn(conn)
c.relayConn = conn
c.datagramFallbackTriggered.Store(false)
instanceURL, err := c.handShake(ctx)
if err != nil {
cErr := conn.Close()