MCPcopy
hub / github.com/moby/moby / NewEchoServer

Function NewEchoServer

cmd/docker-proxy/network_proxy_linux_test.go:48–81  ·  view source on GitHub ↗
(t *testing.T, proto, address string, opts EchoServerOptions)

Source from the content-addressed store, hash-verified

46const hopefullyFreePort = 25587
47
48func NewEchoServer(t *testing.T, proto, address string, opts EchoServerOptions) EchoServer {
49 var server EchoServer
50 if !strings.HasPrefix(proto, "tcp") && opts.TCPHalfClose {
51 t.Fatalf("TCPHalfClose is not supported for %s", proto)
52 }
53
54 switch {
55 case strings.HasPrefix(proto, "tcp"):
56 listener, err := net.Listen(proto, address)
57 if err != nil {
58 t.Fatal(err)
59 }
60 server = &StreamEchoServer{listener: listener, testCtx: t, opts: opts}
61 case strings.HasPrefix(proto, "udp"):
62 socket, err := net.ListenPacket(proto, address)
63 if err != nil {
64 t.Fatal(err)
65 }
66 server = &UDPEchoServer{conn: socket, testCtx: t}
67 case strings.HasPrefix(proto, "sctp"):
68 addr, err := sctp.ResolveSCTPAddr(proto, address)
69 if err != nil {
70 t.Fatal(err)
71 }
72 listener, err := sctp.ListenSCTP(proto, addr)
73 if err != nil {
74 t.Fatal(err)
75 }
76 server = &StreamEchoServer{listener: listener, testCtx: t}
77 default:
78 t.Fatalf("unknown protocol: %s", proto)
79 }
80 return server
81}
82
83func (server *StreamEchoServer) Run() {
84 go func() {

Callers 10

testTCP4ProxyFunction · 0.85
TestTCP6ProxyFunction · 0.85
TestTCPDualStackProxyFunction · 0.85
testUDP4ProxyFunction · 0.85
TestUDP6ProxyFunction · 0.85
TestUDPWriteErrorFunction · 0.85
TestSCTP4ProxyNoListenerFunction · 0.85
TestSCTP6ProxyNoListenerFunction · 0.85
TestSCTP4ProxyFunction · 0.85
TestSCTP6ProxyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…