mirror of
https://github.com/coredns/coredns.git
synced 2026-04-07 20:45:32 -04:00
proxyproto: add UDP session tracking for Spectrum PPv2 (#7967)
This commit is contained in:
@@ -39,7 +39,9 @@ type Server struct {
|
||||
ReadTimeout time.Duration // Read timeout for TCP
|
||||
WriteTimeout time.Duration // Write timeout for TCP
|
||||
|
||||
connPolicy proxyproto.ConnPolicyFunc // Proxy Protocol connection policy function
|
||||
connPolicy proxyproto.ConnPolicyFunc // Proxy Protocol connection policy function
|
||||
udpSessionTrackingTTL time.Duration // TTL for UDP PPv2 session tracking (0 = disabled)
|
||||
udpSessionTrackingMaxSessions int // LRU cap for UDP session tracking (0 = default)
|
||||
|
||||
server [2]*dns.Server // 0 is a net.Listener, 1 is a net.PacketConn (a *UDPConn) in our case.
|
||||
m sync.Mutex // protects the servers
|
||||
@@ -130,6 +132,12 @@ func NewServer(addr string, group []*Config) (*Server, error) {
|
||||
if site.ProxyProtoConnPolicy != nil {
|
||||
s.connPolicy = site.ProxyProtoConnPolicy
|
||||
}
|
||||
if site.ProxyProtoUDPSessionTrackingTTL > 0 {
|
||||
s.udpSessionTrackingTTL = site.ProxyProtoUDPSessionTrackingTTL
|
||||
}
|
||||
if site.ProxyProtoUDPSessionTrackingMaxSessions > 0 {
|
||||
s.udpSessionTrackingMaxSessions = site.ProxyProtoUDPSessionTrackingMaxSessions
|
||||
}
|
||||
}
|
||||
|
||||
if !s.debug {
|
||||
@@ -206,7 +214,7 @@ func (s *Server) ListenPacket() (net.PacketConn, error) {
|
||||
return nil, err
|
||||
}
|
||||
if s.connPolicy != nil {
|
||||
p = &cproxyproto.PacketConn{PacketConn: p, ConnPolicy: s.connPolicy}
|
||||
p = &cproxyproto.PacketConn{PacketConn: p, ConnPolicy: s.connPolicy, UDPSessionTrackingTTL: s.udpSessionTrackingTTL, UDPSessionTrackingMaxSessions: s.udpSessionTrackingMaxSessions}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user