MCPcopy
hub / github.com/moby/moby / testUDP4Proxy

Function testUDP4Proxy

cmd/docker-proxy/network_proxy_linux_test.go:344–370  ·  view source on GitHub ↗
(t *testing.T, hostPort int)

Source from the content-addressed store, hash-verified

342}
343
344func testUDP4Proxy(t *testing.T, hostPort int) {
345 t.Helper()
346 backend := NewEchoServer(t, "udp", "127.0.0.1:0", EchoServerOptions{})
347 defer backend.Close()
348 backend.Run()
349 var listener *os.File
350 frontendAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}
351 if hostPort == 0 {
352 listener, frontendAddr = udpListener(t, "udp4", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
353 } else {
354 frontendAddr.Port = hostPort
355 }
356 backendAddr := backend.LocalAddr().(*net.UDPAddr)
357 config := ProxyConfig{
358 Proto: "udp",
359 HostIP: frontendAddr.IP,
360 HostPort: frontendAddr.Port,
361 ContainerIP: backendAddr.IP,
362 ContainerPort: backendAddr.Port,
363 ListenSock: listener,
364 }
365 proxy, err := newProxy(config)
366 if err != nil {
367 t.Fatal(err)
368 }
369 testProxyAt(t, "udp", proxy, frontendAddr.String(), false)
370}
371
372func TestUDP4Proxy(t *testing.T) {
373 testUDP4Proxy(t, 0)

Callers 2

TestUDP4ProxyFunction · 0.85
TestUDP4ProxyNoListenerFunction · 0.85

Calls 9

CloseMethod · 0.95
RunMethod · 0.95
LocalAddrMethod · 0.95
NewEchoServerFunction · 0.85
udpListenerFunction · 0.85
newProxyFunction · 0.85
testProxyAtFunction · 0.85
HelperMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…