UDP support
Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
parent
8988c8f9af
commit
115d42e0f0
72 changed files with 4730 additions and 321 deletions
26
pkg/udp/switcher.go
Normal file
26
pkg/udp/switcher.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue