|
@@ -1,6 +1,9 @@
|
|
|
package internet
|
|
package internet
|
|
|
|
|
|
|
|
-import "syscall"
|
|
|
|
|
|
|
+import (
|
|
|
|
|
+ "golang.org/x/sys/windows"
|
|
|
|
|
+ "syscall"
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
TCP_FASTOPEN = 15 // nolint: revive,stylecheck
|
|
TCP_FASTOPEN = 15 // nolint: revive,stylecheck
|
|
@@ -32,6 +35,18 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if config.SocketTxBufSize != 0 {
|
|
|
|
|
+ if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
|
|
|
|
|
+ return newError("failed to set SO_SNDBUF").Base(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if config.SocketRxBufSize != 0 {
|
|
|
|
|
+ if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_RCVBUF, int(config.SocketTxBufSize)); err != nil {
|
|
|
|
|
+ return newError("failed to set SO_RCVBUF").Base(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -47,6 +62,18 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if config.SocketTxBufSize != 0 {
|
|
|
|
|
+ if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
|
|
|
|
|
+ return newError("failed to set SO_SNDBUF").Base(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if config.SocketRxBufSize != 0 {
|
|
|
|
|
+ if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_RCVBUF, int(config.SocketTxBufSize)); err != nil {
|
|
|
|
|
+ return newError("failed to set SO_RCVBUF").Base(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|