mirror of https://github.com/cbeuw/Cloak
Make the loopback buffers configurable
This commit is contained in:
parent
786607d31e
commit
4a989ccd14
|
|
@ -26,6 +26,8 @@ type RawConfig struct {
|
|||
DatabasePath string
|
||||
KeepAlive int
|
||||
CncMode bool
|
||||
LoopbackTcpSendBuffer int
|
||||
LoopbackTcpReceiveBuffer int
|
||||
}
|
||||
|
||||
// State type stores the global state of the program
|
||||
|
|
@ -175,14 +177,20 @@ func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, er
|
|||
}
|
||||
|
||||
return c.Control(func(fd uintptr) {
|
||||
err := syscall.SetsockoptInt(platformfd(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 32*1024)
|
||||
if preParse.LoopbackTcpSendBuffer > 0 {
|
||||
log.Debugf("Setting loopback connection tcp send buffer: %d", preParse.LoopbackTcpSendBuffer)
|
||||
err := syscall.SetsockoptInt(platformfd(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, preParse.LoopbackTcpSendBuffer)
|
||||
if err != nil {
|
||||
log.Println("setsocketopt SO_SNDBUF: ", err)
|
||||
log.Errorf("setsocketopt SO_SNDBUF: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
err = syscall.SetsockoptInt(platformfd(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 32*1024)
|
||||
if preParse.LoopbackTcpReceiveBuffer > 0 {
|
||||
log.Debugf("Setting loopback connection tcp receive buffer: %d", preParse.LoopbackTcpReceiveBuffer)
|
||||
err = syscall.SetsockoptInt(platformfd(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, preParse.LoopbackTcpReceiveBuffer)
|
||||
if err != nil {
|
||||
log.Println("setsocketopt SO_RCVBUF: ", err)
|
||||
log.Errorf("setsocketopt SO_RCVBUF: %s\n", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue