MCPcopy
hub / github.com/cloudflare/cloudflared / proxyTCP

Function proxyTCP

orchestration/orchestrator_test.go:500–520  ·  view source on GitHub ↗
(ctx context.Context, originProxy connection.OriginProxy, originAddr string, w http.ResponseWriter, reqBody io.ReadCloser)

Source from the content-addressed store, hash-verified

498}
499
500func proxyTCP(ctx context.Context, originProxy connection.OriginProxy, originAddr string, w http.ResponseWriter, reqBody io.ReadCloser) error {
501 req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", originAddr), reqBody)
502 if err != nil {
503 return err
504 }
505
506 log := zerolog.Nop()
507 respWriter, err := connection.NewHTTP2RespWriter(req, w, connection.TypeTCP, &log)
508 if err != nil {
509 return err
510 }
511
512 tcpReq := &connection.TCPRequest{
513 Dest: originAddr,
514 CFRay: "123",
515 LBProbe: false,
516 }
517 rws := connection.NewHTTPResponseReadWriterAcker(respWriter, w.(http.Flusher), req)
518
519 return originProxy.ProxyTCP(ctx, rws, tcpReq)
520}
521
522func serveTCPOrigin(t *testing.T, tcpOrigin net.Listener, wg *sync.WaitGroup) {
523 for {

Callers 2

TestPersistentConnectionFunction · 0.85

Calls 3

NewHTTP2RespWriterFunction · 0.92
ProxyTCPMethod · 0.65

Tested by

no test coverage detected