mirror of
https://github.com/datarhei/core.git
synced 2025-10-20 06:44:36 +08:00
Upgrade dependencies
This commit is contained in:
65
vendor/github.com/datarhei/gosrt/net.go
generated
vendored
Normal file
65
vendor/github.com/datarhei/gosrt/net.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
//go:build !windows
|
||||
|
||||
package srt
|
||||
|
||||
import "syscall"
|
||||
|
||||
func ListenControl(config Config) func(network, address string, c syscall.RawConn) error {
|
||||
return func(network, address string, c syscall.RawConn) error {
|
||||
var opErr error
|
||||
err := c.Control(func(fd uintptr) {
|
||||
// Set REUSEADDR
|
||||
opErr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 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
|
||||
}
|
||||
}
|
||||
|
||||
func DialControl(config Config) func(network string, address string, c syscall.RawConn) error {
|
||||
return func(network, address string, c syscall.RawConn) error {
|
||||
var opErr error
|
||||
err := c.Control(func(fd uintptr) {
|
||||
// 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user