mirror of
https://github.com/apernet/OpenGFW.git
synced 2024-11-14 14:29:22 +08:00
Merge pull request #85 from apernet/wip-buf
feat: netlink rcv/snd buffer config options
This commit is contained in:
commit
1dce82745d
@ -70,6 +70,8 @@ opkg install kmod-nft-queue kmod-nf-conntrack-netlink
|
|||||||
```yaml
|
```yaml
|
||||||
io:
|
io:
|
||||||
queueSize: 1024
|
queueSize: 1024
|
||||||
|
rcvBuf: 4194304
|
||||||
|
sndBuf: 4194304
|
||||||
local: true # FORWARD チェーンで OpenGFW を実行したい場合は false に設定する
|
local: true # FORWARD チェーンで OpenGFW を実行したい場合は false に設定する
|
||||||
|
|
||||||
workers:
|
workers:
|
||||||
|
@ -74,6 +74,8 @@ opkg install kmod-nft-queue kmod-nf-conntrack-netlink
|
|||||||
```yaml
|
```yaml
|
||||||
io:
|
io:
|
||||||
queueSize: 1024
|
queueSize: 1024
|
||||||
|
rcvBuf: 4194304
|
||||||
|
sndBuf: 4194304
|
||||||
local: true # set to false if you want to run OpenGFW on FORWARD chain
|
local: true # set to false if you want to run OpenGFW on FORWARD chain
|
||||||
|
|
||||||
workers:
|
workers:
|
||||||
|
@ -70,6 +70,8 @@ opkg install kmod-nft-queue kmod-nf-conntrack-netlink
|
|||||||
```yaml
|
```yaml
|
||||||
io:
|
io:
|
||||||
queueSize: 1024
|
queueSize: 1024
|
||||||
|
rcvBuf: 4194304
|
||||||
|
sndBuf: 4194304
|
||||||
local: true # 如果需要在 FORWARD 链上运行 OpenGFW,请设置为 false
|
local: true # 如果需要在 FORWARD 链上运行 OpenGFW,请设置为 false
|
||||||
|
|
||||||
workers:
|
workers:
|
||||||
|
12
cmd/root.go
12
cmd/root.go
@ -168,8 +168,10 @@ type cliConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type cliConfigIO struct {
|
type cliConfigIO struct {
|
||||||
QueueSize uint32 `mapstructure:"queueSize"`
|
QueueSize uint32 `mapstructure:"queueSize"`
|
||||||
Local bool `mapstructure:"local"`
|
ReadBuffer int `mapstructure:"rcvBuf"`
|
||||||
|
WriteBuffer int `mapstructure:"sndBuf"`
|
||||||
|
Local bool `mapstructure:"local"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type cliConfigWorkers struct {
|
type cliConfigWorkers struct {
|
||||||
@ -192,8 +194,10 @@ func (c *cliConfig) fillLogger(config *engine.Config) error {
|
|||||||
|
|
||||||
func (c *cliConfig) fillIO(config *engine.Config) error {
|
func (c *cliConfig) fillIO(config *engine.Config) error {
|
||||||
nfio, err := io.NewNFQueuePacketIO(io.NFQueuePacketIOConfig{
|
nfio, err := io.NewNFQueuePacketIO(io.NFQueuePacketIOConfig{
|
||||||
QueueSize: c.IO.QueueSize,
|
QueueSize: c.IO.QueueSize,
|
||||||
Local: c.IO.Local,
|
ReadBuffer: c.IO.ReadBuffer,
|
||||||
|
WriteBuffer: c.IO.WriteBuffer,
|
||||||
|
Local: c.IO.Local,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return configError{Field: "io", Err: err}
|
return configError{Field: "io", Err: err}
|
||||||
|
@ -97,8 +97,10 @@ type nfqueuePacketIO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NFQueuePacketIOConfig struct {
|
type NFQueuePacketIOConfig struct {
|
||||||
QueueSize uint32
|
QueueSize uint32
|
||||||
Local bool
|
ReadBuffer int
|
||||||
|
WriteBuffer int
|
||||||
|
Local bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
|
func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
|
||||||
@ -128,6 +130,20 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if config.ReadBuffer > 0 {
|
||||||
|
err = n.Con.SetReadBuffer(config.ReadBuffer)
|
||||||
|
if err != nil {
|
||||||
|
_ = n.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if config.WriteBuffer > 0 {
|
||||||
|
err = n.Con.SetWriteBuffer(config.WriteBuffer)
|
||||||
|
if err != nil {
|
||||||
|
_ = n.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
return &nfqueuePacketIO{
|
return &nfqueuePacketIO{
|
||||||
n: n,
|
n: n,
|
||||||
local: config.Local,
|
local: config.Local,
|
||||||
|
Loading…
Reference in New Issue
Block a user