diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2022-09-21 12:55:23 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 12:55:23 -0600 |
commit | 1426c97da57fc84d8b584a960c43fbb58df68b80 (patch) | |
tree | 2e4a70639a4767d2ad728fad37fd1512091518c7 /listen_linux.go | |
parent | 44ad0cedafcd32d5edcf3c6ed62834641d10fa2f (diff) |
core: Reuse unix sockets (UDS) and don't try to serve HTTP/3 over UDS (#5063)
* core: Reuse unix sockets
* Don't serve HTTP/3 over unix sockets
This requires upstream support, if even useful
* Don't use unix build tag... yet
* Fix build tag
* Allow ErrNotExist when unlinking socket
Diffstat (limited to 'listen_linux.go')
-rw-r--r-- | listen_linux.go | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/listen_linux.go b/listen_linux.go deleted file mode 100644 index b1220ce..0000000 --- a/listen_linux.go +++ /dev/null @@ -1,34 +0,0 @@ -package caddy - -import ( - "context" - "net" - "syscall" - "time" - - "go.uber.org/zap" - "golang.org/x/sys/unix" -) - -// ListenTimeout is the same as Listen, but with a configurable keep-alive timeout duration. -func ListenTimeout(network, addr string, keepalivePeriod time.Duration) (net.Listener, error) { - // check to see if plugin provides listener - if ln, err := getListenerFromPlugin(network, addr); err != nil || ln != nil { - return ln, err - } - - config := &net.ListenConfig{Control: reusePort, KeepAlive: keepalivePeriod} - return config.Listen(context.Background(), network, addr) -} - -func reusePort(network, address string, conn syscall.RawConn) error { - return conn.Control(func(descriptor uintptr) { - if err := unix.SetsockoptInt(int(descriptor), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { - Log().Error("setting SO_REUSEPORT", - zap.String("network", network), - zap.String("address", address), - zap.Uintptr("descriptor", descriptor), - zap.Error(err)) - } - }) -} |