refactor(mdns): consolidate platform-specific syscall files

- Rename `syscall_linux.go` to `syscall.go` with build constraints for non-BSD and non-Windows platforms.
- Merge `syscall_darwin.go` into `syscall_bsd.go` and adjust build constraints for BSD platforms (Darwin, FreeBSD, OpenBSD).
- Remove redundant `syscall_freebsd.go`.
- Add build constraints to `syscall_windows.go` for Windows platform.
This commit is contained in:
Sergey Krashevich
2024-04-30 01:49:01 +03:00
parent 732fe47836
commit e080eac204
4 changed files with 6 additions and 24 deletions
@@ -1,3 +1,5 @@
//go:build !(darwin || ios || freebsd || openbsd || netbsd || dragonfly || windows)
package mdns package mdns
import ( import (
@@ -1,3 +1,5 @@
//go:build darwin || ios || freebsd || openbsd || netbsd || dragonfly
package mdns package mdns
import ( import (
-24
View File
@@ -1,24 +0,0 @@
package mdns
import (
"syscall"
)
func SetsockoptInt(fd uintptr, level, opt int, value int) (err error) {
// change SO_REUSEADDR and REUSEPORT flags simultaneously for BSD-like OS
// https://github.com/AlexxIT/go2rtc/issues/626
// https://stackoverflow.com/questions/14388706/how-do-so-reuseaddr-and-so-reuseport-differ/14388707
if opt == syscall.SO_REUSEADDR {
if err = syscall.SetsockoptInt(int(fd), level, opt, value); err != nil {
return
}
opt = syscall.SO_REUSEPORT
}
return syscall.SetsockoptInt(int(fd), level, opt, value)
}
func SetsockoptIPMreq(fd uintptr, level, opt int, mreq *syscall.IPMreq) (err error) {
return syscall.SetsockoptIPMreq(int(fd), level, opt, mreq)
}
+2
View File
@@ -1,3 +1,5 @@
//go:build windows
package mdns package mdns
import "syscall" import "syscall"