1
0
Fork 0

UDP support

Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
mpl 2020-02-11 01:26:04 +01:00 committed by GitHub
parent 8988c8f9af
commit 115d42e0f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 4730 additions and 321 deletions

26
pkg/udp/switcher.go Normal file
View file

@ -0,0 +1,26 @@
package udp
import (
"github.com/containous/traefik/v2/pkg/safe"
)
// HandlerSwitcher is a switcher implementation of the Handler interface.
type HandlerSwitcher struct {
handler safe.Safe
}
// ServeUDP implements the Handler interface.
func (s *HandlerSwitcher) ServeUDP(conn *Conn) {
handler := s.handler.Get()
h, ok := handler.(Handler)
if ok {
h.ServeUDP(conn)
} else {
conn.Close()
}
}
// Switch replaces s handler with the given handler.
func (s *HandlerSwitcher) Switch(handler Handler) {
s.handler.Set(handler)
}