(ctx context.Context, orchestratorIP string, orchestratorPort int, localPort int, udpConn *net.UDPConn, done chan<- error)
| 136 | } |
| 137 | |
| 138 | func startQUICClient(ctx context.Context, orchestratorIP string, orchestratorPort int, localPort int, udpConn *net.UDPConn, done chan<- error) { |
| 139 | // Connect to orchestrator's QUIC server using the same local port |
| 140 | remoteAddr := fmt.Sprintf("%s:%d", orchestratorIP, orchestratorPort) |
| 141 | |
| 142 | tlsConfig := &tls.Config{ |
| 143 | InsecureSkipVerify: true, |
| 144 | NextProtos: []string{"h3"}, |
| 145 | } |
| 146 | |
| 147 | // Get local address for port reuse |
| 148 | localAddr := udpConn.LocalAddr().(*net.UDPAddr) |
| 149 | |
| 150 | // Close UDP socket gracefully |
| 151 | shared.CloseUDPSocketGracefully(udpConn) |
| 152 | |
| 153 | // Parse remote address |
| 154 | remoteUDPAddr, err := net.ResolveUDPAddr("udp", remoteAddr) |
| 155 | if err != nil { |
| 156 | shared.LogError("Failed to resolve orchestrator address", err) |
| 157 | done <- err |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | shared.LogConnectionf("Connecting to orchestrator QUIC server at %s from local port %d", remoteAddr, localAddr.Port) |
| 162 | |
| 163 | // Create UDP connection on same local port |
| 164 | udpDialConn, err := shared.ReuseUDPPort(localAddr) |
| 165 | if err != nil { |
| 166 | shared.LogError("Failed to create UDP connection", err) |
| 167 | done <- err |
| 168 | return |
| 169 | } |
| 170 | |
| 171 | // Create high-performance QUIC configuration (same as server) |
| 172 | quicConfig := &quic.Config{ |
| 173 | // Flow control optimization for streaming |
| 174 | InitialStreamReceiveWindow: shared.QUICInitialStreamReceiveWindow, |
| 175 | MaxStreamReceiveWindow: shared.QUICMaxStreamReceiveWindow, |
| 176 | InitialConnectionReceiveWindow: shared.QUICInitialConnectionReceiveWindow, |
| 177 | MaxConnectionReceiveWindow: shared.QUICMaxConnectionReceiveWindow, |
| 178 | |
| 179 | // Stream limits for concurrent connections |
| 180 | MaxIncomingStreams: shared.QUICMaxIncomingStreams, |
| 181 | MaxIncomingUniStreams: shared.QUICMaxIncomingUniStreams, |
| 182 | |
| 183 | // Timeout optimization |
| 184 | MaxIdleTimeout: shared.QUICIdleTimeout, |
| 185 | HandshakeIdleTimeout: shared.QUICHandshakeTimeout, |
| 186 | KeepAlivePeriod: shared.QUICKeepAlive, |
| 187 | |
| 188 | // Enable connection migration for better reliability |
| 189 | DisablePathMTUDiscovery: false, |
| 190 | EnableDatagrams: false, // Focus on stream performance |
| 191 | } |
| 192 | |
| 193 | // Connect to orchestrator's QUIC server with optimized config |
| 194 | quicConn, err := quic.Dial(ctx, udpDialConn, remoteUDPAddr, tlsConfig, quicConfig) |
| 195 | if err != nil { |
no test coverage detected