Merge branch 'dev' into cluster

This commit is contained in:
Ingo Oppermann 2022-08-17 10:03:21 +03:00
commit 4e8e4a2ad9
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
4 changed files with 42 additions and 32 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/99designs/gqlgen v0.17.13
github.com/Masterminds/semver/v3 v3.1.1
github.com/atrox/haikunatorgo/v2 v2.0.1
github.com/datarhei/gosrt v0.2.1-0.20220812130440-71bf5952f57e
github.com/datarhei/gosrt v0.2.1-0.20220817065416-5d1fd7a090e5
github.com/datarhei/joy4 v0.0.0-20220728180719-f752080f4a36
github.com/go-playground/validator/v10 v10.11.0
github.com/gobwas/glob v0.2.3

4
go.sum
View File

@ -76,8 +76,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/datarhei/gosrt v0.2.1-0.20220812130440-71bf5952f57e h1:0TwcuTPTumn12D0AGfephlJr5FZ/wDG31BHjaOCIN9E=
github.com/datarhei/gosrt v0.2.1-0.20220812130440-71bf5952f57e/go.mod h1:wyoTu+DG45XRuCgEq/y+R8nhZCrJbOyQKn+SwNrNVZ8=
github.com/datarhei/gosrt v0.2.1-0.20220817065416-5d1fd7a090e5 h1:lTmd1w7UpULXD/B6LfRu4QJHDILq9W5atyLP+RCkoMA=
github.com/datarhei/gosrt v0.2.1-0.20220817065416-5d1fd7a090e5/go.mod h1:wyoTu+DG45XRuCgEq/y+R8nhZCrJbOyQKn+SwNrNVZ8=
github.com/datarhei/joy4 v0.0.0-20220728180719-f752080f4a36 h1:ppjcv7wazy4d7vANREERXkSAUnhV/nfT2a+13u4ZijQ=
github.com/datarhei/joy4 v0.0.0-20220728180719-f752080f4a36/go.mod h1:Jcw/6jZDQQmPx8A7INEkXmuEF7E9jjBbSTfVSLwmiQw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View File

@ -157,7 +157,8 @@ type listener struct {
// The address has the form "host:port".
//
// Examples:
// Listen("srt", "127.0.0.1:3000", DefaultConfig())
//
// Listen("srt", "127.0.0.1:3000", DefaultConfig())
//
// In case of an error, the returned Listener is nil and the error is non-nil.
func Listen(network, address string, config Config) (Listener, error) {
@ -177,36 +178,45 @@ func Listen(network, address string, config Config) (Listener, error) {
config: config,
}
raddr, err := net.ResolveUDPAddr("udp", address)
lc := net.ListenConfig{
Control: func(network, address string, c syscall.RawConn) error {
var opErr error
err := c.Control(func(fd uintptr) {
// Set REUSEPORT
opErr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
if opErr != nil {
return
}
// Set TOS
if config.IPTOS > 0 {
opErr = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, config.IPTOS)
if opErr != nil {
return
}
}
// Set TTL
if config.IPTTL > 0 {
opErr = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TTL, config.IPTTL)
if opErr != nil {
return
}
}
})
if err != nil {
return err
}
return opErr
},
}
lp, err := lc.ListenPacket(context.Background(), "udp", address)
if err != nil {
return nil, fmt.Errorf("listen: unable to resolve address: %w", err)
return nil, fmt.Errorf("listen: %w", err)
}
pc, err := net.ListenUDP("udp", raddr)
if err != nil {
return nil, fmt.Errorf("listen: failed listening: %w", err)
}
file, err := pc.File()
if err != nil {
return nil, err
}
// Set TOS
if config.IPTOS > 0 {
err = syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_TOS, config.IPTOS)
if err != nil {
return nil, fmt.Errorf("listen: failed setting socket option TOS: %w", err)
}
}
// Set TTL
if config.IPTTL > 0 {
err = syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_TTL, config.IPTTL)
if err != nil {
return nil, fmt.Errorf("listen: failed setting socket option TTL: %w", err)
}
}
pc := lp.(*net.UDPConn)
ln.pc = pc
ln.addr = pc.LocalAddr()

2
vendor/modules.txt vendored
View File

@ -48,7 +48,7 @@ github.com/cespare/xxhash/v2
# github.com/cpuguy83/go-md2man/v2 v2.0.1
## explicit; go 1.11
github.com/cpuguy83/go-md2man/v2/md2man
# github.com/datarhei/gosrt v0.2.1-0.20220812130440-71bf5952f57e
# github.com/datarhei/gosrt v0.2.1-0.20220817065416-5d1fd7a090e5
## explicit; go 1.16
github.com/datarhei/gosrt
github.com/datarhei/gosrt/internal/circular