mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-07-04 10:19:51 +00:00
fix: timeval in different arch
Signed-off-by: HystericalDragon <HystericalDragons@proton.me>
This commit is contained in:
parent
13586df2ba
commit
9520d84094
@ -58,11 +58,7 @@ func fdControlUnixSocketImpl(c *net.UDPConn, path string) error {
|
|||||||
}
|
}
|
||||||
defer unix.Close(socketFd)
|
defer unix.Close(socketFd)
|
||||||
|
|
||||||
timeoutUsec := fdControlUnixTimeout.Microseconds()
|
timeout := unixTimeval()
|
||||||
timeout := unix.Timeval{
|
|
||||||
Sec: timeoutUsec / 1e6,
|
|
||||||
Usec: timeoutUsec % 1e6,
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = unix.SetsockoptTimeval(socketFd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &timeout)
|
_ = unix.SetsockoptTimeval(socketFd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &timeout)
|
||||||
_ = unix.SetsockoptTimeval(socketFd, unix.SOL_SOCKET, unix.SO_SNDTIMEO, &timeout)
|
_ = unix.SetsockoptTimeval(socketFd, unix.SOL_SOCKET, unix.SO_SNDTIMEO, &timeout)
|
||||||
|
15
app/internal/sockopts/timeval_linux_32.go
Normal file
15
app/internal/sockopts/timeval_linux_32.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//go:build linux && (386 || arm || mips || mipsle || ppc)
|
||||||
|
|
||||||
|
package sockopts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unixTimeval() unix.Timeval {
|
||||||
|
timeUsec := fdControlUnixTimeout.Microseconds()
|
||||||
|
return unix.Timeval{
|
||||||
|
Sec: int32(timeUsec / 1e6),
|
||||||
|
Usec: int32(timeUsec % 1e6),
|
||||||
|
}
|
||||||
|
}
|
15
app/internal/sockopts/timeval_linux_64.go
Normal file
15
app/internal/sockopts/timeval_linux_64.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//go:build linux && (amd64 || arm64 || loong64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || sparc64)
|
||||||
|
|
||||||
|
package sockopts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unixTimeval() unix.Timeval {
|
||||||
|
timeUsec := fdControlUnixTimeout.Microseconds()
|
||||||
|
return unix.Timeval{
|
||||||
|
Sec: timeUsec / 1e6,
|
||||||
|
Usec: timeUsec % 1e6,
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user