Add support for UDP routing in systemd socket activation
This commit is contained in:
parent
95dd17e020
commit
261e4395f3
9 changed files with 158 additions and 54 deletions
41
pkg/server/socket_activation.go
Normal file
41
pkg/server/socket_activation.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
type SocketActivation struct {
|
||||
enabled bool
|
||||
listeners map[string]net.Listener
|
||||
conns map[string]net.PacketConn
|
||||
}
|
||||
|
||||
func (s *SocketActivation) isEnabled() bool {
|
||||
return s.enabled
|
||||
}
|
||||
|
||||
func (s *SocketActivation) getListener(name string) (net.Listener, error) {
|
||||
listener, ok := s.listeners[name]
|
||||
if !ok {
|
||||
return nil, errors.New("unable to find socket activation TCP listener for entryPoint")
|
||||
}
|
||||
|
||||
return listener, nil
|
||||
}
|
||||
|
||||
func (s *SocketActivation) getConn(name string) (net.PacketConn, error) {
|
||||
conn, ok := s.conns[name]
|
||||
if !ok {
|
||||
return nil, errors.New("unable to find socket activation UDP listener for entryPoint")
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
var socketActivation *SocketActivation
|
||||
|
||||
func init() {
|
||||
// Populates pre-defined TCP and UDP listeners provided by systemd socket activation.
|
||||
socketActivation = populateSocketActivationListeners()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue