mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-06-12 10:19:23 +00:00
8696a8cdf0
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.50 to 1.1.51. - [Release notes](https://github.com/miekg/dns/releases) - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.50...v1.1.51) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
46 lines
972 B
Go
46 lines
972 B
Go
//go:build go1.11 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd)
|
|
// +build go1.11
|
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd
|
|
|
|
package dns
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
const supportsReusePort = true
|
|
|
|
func reuseportControl(network, address string, c syscall.RawConn) error {
|
|
var opErr error
|
|
err := c.Control(func(fd uintptr) {
|
|
opErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return opErr
|
|
}
|
|
|
|
func listenTCP(network, addr string, reuseport bool) (net.Listener, error) {
|
|
var lc net.ListenConfig
|
|
if reuseport {
|
|
lc.Control = reuseportControl
|
|
}
|
|
|
|
return lc.Listen(context.Background(), network, addr)
|
|
}
|
|
|
|
func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) {
|
|
var lc net.ListenConfig
|
|
if reuseport {
|
|
lc.Control = reuseportControl
|
|
}
|
|
|
|
return lc.ListenPacket(context.Background(), network, addr)
|
|
}
|