@@ -52,9 +52,9 @@ func NewHTTP3Transport(tlsConfig *tls.Config) *HTTP3Transport {
5252 return & HTTP3Transport {
5353 TLSClientConfig : tlsConfig ,
5454 QuicConfig : & quic.Config {
55- HandshakeIdleTimeout : 30 * time .Second ,
56- MaxIdleTimeout : 90 * time .Second ,
57- KeepAlivePeriod : 15 * time .Second ,
55+ HandshakeIdleTimeout : 30 * time .Second ,
56+ MaxIdleTimeout : 90 * time .Second ,
57+ KeepAlivePeriod : 15 * time .Second ,
5858 },
5959 UQuicConfig : nil , // Will be set when QUIC fingerprint is provided
6060 QUICSpec : nil , // Will be set when QUIC fingerprint is provided
@@ -114,9 +114,9 @@ func (t *UQuicHTTP3Transport) RoundTrip(req *http.Request) (*http.Response, erro
114114 Transport : & http3.Transport {
115115 TLSClientConfig : t .TLSClientConfig ,
116116 QUICConfig : & quic.Config {
117- HandshakeIdleTimeout : 30 * time .Second ,
118- MaxIdleTimeout : 90 * time .Second ,
119- KeepAlivePeriod : 15 * time .Second ,
117+ HandshakeIdleTimeout : 30 * time .Second ,
118+ MaxIdleTimeout : 90 * time .Second ,
119+ KeepAlivePeriod : 15 * time .Second ,
120120 },
121121 },
122122 }
@@ -262,9 +262,9 @@ func ConfigureHTTP3Client(client *stdhttp.Client, tlsConfig *tls.Config) {
262262 client .Transport = & http3.Transport {
263263 TLSClientConfig : tlsConfig ,
264264 QUICConfig : & quic.Config {
265- HandshakeIdleTimeout : 30 * time .Second ,
266- MaxIdleTimeout : 90 * time .Second ,
267- KeepAlivePeriod : 15 * time .Second ,
265+ HandshakeIdleTimeout : 30 * time .Second ,
266+ MaxIdleTimeout : 90 * time .Second ,
267+ KeepAlivePeriod : 15 * time .Second ,
268268 },
269269 }
270270}
@@ -408,13 +408,13 @@ func (rt *roundTripper) http3Dial(ctx context.Context, remoteAddr, port string,
408408 // TODO: Implement proper CONNECT-UDP proxy support for HTTP/3
409409 return nil , fmt .Errorf ("HTTP/3 proxy support not yet implemented" )
410410 }
411-
411+
412412 // Direct UDP connection
413413 conn , err := net .ListenPacket ("udp" , "" )
414414 if err != nil {
415415 return nil , fmt .Errorf ("failed to create UDP packet connection: %w" , err )
416416 }
417-
417+
418418 return conn , nil
419419}
420420
@@ -425,7 +425,7 @@ func (rt *roundTripper) ghttp3Dial(ctx context.Context, remoteAddr, port string,
425425 if err != nil {
426426 return nil , err
427427 }
428-
428+
429429 // Configure TLS - use crypto/tls.Config for standard QUIC (matches reference implementation)
430430 var tlsConfig * tls.Config
431431 if rt .TLSConfig != nil {
@@ -439,8 +439,12 @@ func (rt *roundTripper) ghttp3Dial(ctx context.Context, remoteAddr, port string,
439439 tlsConfig = & tls.Config {}
440440 }
441441 tlsConfig .NextProtos = []string {http3 .NextProtoH3 }
442- tlsConfig .ServerName = remoteAddr
443-
442+ if rt .ServerName != "" {
443+ tlsConfig .ServerName = rt .ServerName
444+ } else {
445+ tlsConfig .ServerName = remoteAddr
446+ }
447+
444448 // Resolve remote address
445449 remoteHost := remoteAddr
446450 if net .ParseIP (remoteAddr ) == nil {
@@ -457,15 +461,15 @@ func (rt *roundTripper) ghttp3Dial(ctx context.Context, remoteAddr, port string,
457461 // Use the first IP address
458462 remoteHost = ips [0 ].String ()
459463 }
460-
464+
461465 // Convert port to integer
462466 portInt := 443
463467 if port != "" {
464468 if p , err := net .LookupPort ("tcp" , port ); err == nil {
465469 portInt = p
466470 }
467471 }
468-
472+
469473 // Configure QUIC - conditional setup like reference implementation
470474 var quicConfig * quic.Config
471475 // TODO: Add support for rt.UquicConfig when it's available
@@ -486,19 +490,19 @@ func (rt *roundTripper) ghttp3Dial(ctx context.Context, remoteAddr, port string,
486490 Allow0RTT : false , // Security consideration
487491 }
488492 }
489-
493+
490494 // Establish QUIC connection
491495 remoteUDPAddr := & net.UDPAddr {
492496 IP : net .ParseIP (remoteHost ),
493497 Port : portInt ,
494498 }
495-
499+
496500 quicConn , err := quic .DialEarly (ctx , udpConn , remoteUDPAddr , tlsConfig , quicConfig )
497501 if err != nil {
498502 udpConn .Close ()
499503 return nil , fmt .Errorf ("failed to establish QUIC connection: %w" , err )
500504 }
501-
505+
502506 return & HTTP3Connection {
503507 QuicConn : quicConn ,
504508 RawConn : udpConn ,
@@ -514,15 +518,19 @@ func (rt *roundTripper) uhttp3Dial(ctx context.Context, spec *uquic.QUICSpec, re
514518 if err != nil {
515519 return nil , err
516520 }
517-
521+
518522 // Configure TLS with uTLS config - use utls.Config directly (matches reference implementation)
519523 if rt .TLSConfig == nil {
520524 return nil , fmt .Errorf ("TLS config is required for UQuic HTTP/3" )
521525 }
522526 tlsConfig := rt .TLSConfig .Clone ()
523527 tlsConfig .NextProtos = []string {http3 .NextProtoH3 }
524- tlsConfig .ServerName = remoteAddr
525-
528+ if rt .ServerName != "" {
529+ tlsConfig .ServerName = rt .ServerName
530+ } else {
531+ tlsConfig .ServerName = remoteAddr
532+ }
533+
526534 // Resolve remote address
527535 remoteHost := remoteAddr
528536 if net .ParseIP (remoteAddr ) == nil {
@@ -539,43 +547,43 @@ func (rt *roundTripper) uhttp3Dial(ctx context.Context, spec *uquic.QUICSpec, re
539547 // Use the first IP address
540548 remoteHost = ips [0 ].String ()
541549 }
542-
550+
543551 // Convert port to integer
544552 portInt := 443
545553 if port != "" {
546554 if p , err := net .LookupPort ("tcp" , port ); err == nil {
547555 portInt = p
548556 }
549557 }
550-
551- // Configure UQuic - conditional setup like reference implementation
558+
559+ // Configure UQuic - conditional setup like reference implementation
552560 var uquicConfig * uquic.Config
553561 // TODO: Add support for rt.UquicConfig when it's available
554562 // For now, use default UQuic config similar to reference behavior
555563 if uquicConfig == nil {
556564 uquicConfig = & uquic.Config {}
557565 }
558-
566+
559567 // Create UQuic transport
560568 uTransport := & uquic.UTransport {
561569 Transport : & uquic.Transport {
562570 Conn : udpConn ,
563571 },
564572 QUICSpec : spec ,
565573 }
566-
574+
567575 // Establish QUIC connection with UQuic
568576 remoteUDPAddr := & net.UDPAddr {
569577 IP : net .ParseIP (remoteHost ),
570578 Port : portInt ,
571579 }
572-
580+
573581 quicConn , err := uTransport .DialEarly (ctx , remoteUDPAddr , tlsConfig , uquicConfig )
574582 if err != nil {
575583 udpConn .Close ()
576584 return nil , fmt .Errorf ("failed to establish UQuic connection: %w" , err )
577585 }
578-
586+
579587 return & HTTP3Connection {
580588 QuicConn : quicConn ,
581589 RawConn : udpConn ,
0 commit comments