proxyTCPStream proxies private network type TCP connections as a stream towards an available origin. This is different than proxyStream because it's not leveraged ingress rule services and uses the originDialer from OriginDialerService.
( tr *tracing.TracedContext, tunnelConn connection.ReadWriteAcker, dest netip.AddrPort, originDialer ingress.OriginTCPDialer, logger *zerolog.Logger, )
| 314 | // This is different than proxyStream because it's not leveraged ingress rule services and uses the |
| 315 | // originDialer from OriginDialerService. |
| 316 | func (p *Proxy) proxyTCPStream( |
| 317 | tr *tracing.TracedContext, |
| 318 | tunnelConn connection.ReadWriteAcker, |
| 319 | dest netip.AddrPort, |
| 320 | originDialer ingress.OriginTCPDialer, |
| 321 | logger *zerolog.Logger, |
| 322 | ) error { |
| 323 | ctx := tr.Context |
| 324 | _, connectSpan := tr.Tracer().Start(ctx, "stream-connect") |
| 325 | |
| 326 | start := time.Now() |
| 327 | originConn, err := originDialer.DialTCP(ctx, dest) |
| 328 | if err != nil { |
| 329 | connectStreamErrors.Inc() |
| 330 | tracing.EndWithErrorStatus(connectSpan, err) |
| 331 | return err |
| 332 | } |
| 333 | connectSpan.End() |
| 334 | defer func() { _ = originConn.Close() }() |
| 335 | logger.Debug().Msg("origin connection established") |
| 336 | |
| 337 | encodedSpans := tr.GetSpans() |
| 338 | |
| 339 | if err := tunnelConn.AckConnection(encodedSpans); err != nil { |
| 340 | connectStreamErrors.Inc() |
| 341 | return err |
| 342 | } |
| 343 | |
| 344 | connectLatency.Observe(float64(time.Since(start).Milliseconds())) |
| 345 | logger.Debug().Msg("proxy stream acknowledged") |
| 346 | |
| 347 | stream.Pipe(tunnelConn, originConn, logger) |
| 348 | return nil |
| 349 | } |
| 350 | |
| 351 | func (p *Proxy) proxyLocalRequest(proxy ingress.HTTPLocalProxy, w connection.ResponseWriter, req *http.Request, isWebsocket bool) { |
| 352 | if isWebsocket { |
no test coverage detected