mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-09 02:30:05 +08:00
Chore: use tcpip.Error
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||||
@@ -65,21 +64,21 @@ func withTCPHandler(handle adapter.TCPHandleFunc) option.Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setKeepalive(ep tcpip.Endpoint) error {
|
func setKeepalive(ep tcpip.Endpoint) tcpip.Error {
|
||||||
ep.SocketOptions().SetKeepAlive(true)
|
ep.SocketOptions().SetKeepAlive(true)
|
||||||
|
|
||||||
idle := tcpip.KeepaliveIdleOption(tcpKeepaliveIdle)
|
idle := tcpip.KeepaliveIdleOption(tcpKeepaliveIdle)
|
||||||
if err := ep.SetSockOpt(&idle); err != nil {
|
if err := ep.SetSockOpt(&idle); err != nil {
|
||||||
return fmt.Errorf("set keepalive idle: %s", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
interval := tcpip.KeepaliveIntervalOption(tcpKeepaliveInterval)
|
interval := tcpip.KeepaliveIntervalOption(tcpKeepaliveInterval)
|
||||||
if err := ep.SetSockOpt(&interval); err != nil {
|
if err := ep.SetSockOpt(&interval); err != nil {
|
||||||
return fmt.Errorf("set keepalive interval: %s", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ep.SetSockOptInt(tcpip.KeepaliveCountOption, tcpKeepaliveCount); err != nil {
|
if err := ep.SetSockOptInt(tcpip.KeepaliveCountOption, tcpKeepaliveCount); err != nil {
|
||||||
return fmt.Errorf("set keepalive count: %s", err)
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user