MCPcopy
hub / github.com/valyala/fasthttp / wrapPerIPConn

Function wrapPerIPConn

server.go:2151–2164  ·  view source on GitHub ↗
(s *Server, c net.Conn)

Source from the content-addressed store, hash-verified

2149}
2150
2151func wrapPerIPConn(s *Server, c net.Conn) net.Conn {
2152 ip := getUint32IP(c)
2153 if ip == 0 {
2154 return c
2155 }
2156 n := s.perIPConnCounter.Register(ip)
2157 if n > s.MaxConnsPerIP {
2158 s.perIPConnCounter.Unregister(ip)
2159 s.writeFastError(c, StatusTooManyRequests, "The number of connections from your ip exceeds MaxConnsPerIP")
2160 c.Close()
2161 return nil
2162 }
2163 return acquirePerIPConn(c, ip, &s.perIPConnCounter)
2164}
2165
2166var defaultLogger = Logger(log.New(os.Stderr, "", log.LstdFlags))
2167

Callers 2

acceptConnFunction · 0.85
ServeConnMethod · 0.85

Calls 6

getUint32IPFunction · 0.85
acquirePerIPConnFunction · 0.85
RegisterMethod · 0.80
UnregisterMethod · 0.80
writeFastErrorMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…