MCPcopy
hub / github.com/monasticacademy/httptap / notifyTCP

Method notifyTCP

mux.go:129–141  ·  view source on GitHub ↗

notifyTCP is called when a new stream is created. It finds the first listener that will accept the given stream. It never blocks.

(req TCPRequest)

Source from the content-addressed store, hash-verified

127// notifyTCP is called when a new stream is created. It finds the first listener
128// that will accept the given stream. It never blocks.
129func (s *mux) notifyTCP(req TCPRequest) {
130 s.mu.Lock()
131 defer s.mu.Unlock()
132
133 for _, entry := range s.tcpHandlers {
134 if patternMatches(entry.pattern, req.LocalAddr()) {
135 go entry.handler(req)
136 return
137 }
138 }
139
140 verbosef("nobody listening for tcp to %v, dropping", req.LocalAddr())
141}
142
143// notifyUDP is called when a new packet arrives. It finds the first handler
144// with a pattern that matches the packet and delivers the packet to it

Callers 2

MainFunction · 0.95
handlePacketMethod · 0.80

Calls 3

patternMatchesFunction · 0.85
verbosefFunction · 0.70
LocalAddrMethod · 0.65

Tested by

no test coverage detected