MCPcopy
hub / github.com/moby/moby / testTCP4Proxy

Function testTCP4Proxy

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

Source from the content-addressed store, hash-verified

256}
257
258func testTCP4Proxy(t *testing.T, halfClose bool, hostPort int) {
259 t.Helper()
260 backend := NewEchoServer(t, "tcp", "127.0.0.1:0", EchoServerOptions{TCPHalfClose: halfClose})
261 defer backend.Close()
262 backend.Run()
263 backendAddr := backend.LocalAddr().(*net.TCPAddr)
264 var listener *os.File
265 frontendAddr := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}
266 if hostPort == 0 {
267 listener, frontendAddr = tcpListener(t, "tcp4", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
268 } else {
269 frontendAddr.Port = hostPort
270 }
271 config := ProxyConfig{
272 Proto: "tcp",
273 HostIP: frontendAddr.IP,
274 HostPort: frontendAddr.Port,
275 ContainerIP: backendAddr.IP,
276 ContainerPort: backendAddr.Port,
277 ListenSock: listener,
278 }
279 proxy, err := newProxy(config)
280 if err != nil {
281 t.Fatal(err)
282 }
283 testProxyAt(t, "tcp", proxy, frontendAddr.String(), halfClose)
284}
285
286func TestTCP4Proxy(t *testing.T) {
287 testTCP4Proxy(t, false, 0)

Callers 3

TestTCP4ProxyFunction · 0.85
TestTCP4ProxyNoListenerFunction · 0.85
TestTCP4ProxyHalfCloseFunction · 0.85

Calls 9

CloseMethod · 0.95
RunMethod · 0.95
LocalAddrMethod · 0.95
NewEchoServerFunction · 0.85
tcpListenerFunction · 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…