fix udp bind

This commit is contained in:
ginuerzh
2021-11-22 17:52:38 +08:00
parent 3fd3b5e801
commit 8861644bbc
18 changed files with 477 additions and 613 deletions

View File

@ -1,6 +1,8 @@
package connector
import (
"time"
"github.com/go-gost/gost/pkg/logger"
)
@ -22,7 +24,11 @@ type ConnectOptions struct {
type ConnectOption func(opts *ConnectOptions)
type BindOptions struct {
Mux bool
Mux bool
Backlog int
UDPDataQueueSize int
UDPDataBufferSize int
UDPConnTTL time.Duration
}
type BindOption func(opts *BindOptions)
@ -32,3 +38,27 @@ func MuxBindOption(mux bool) BindOption {
opts.Mux = mux
}
}
func BacklogBindOption(backlog int) BindOption {
return func(opts *BindOptions) {
opts.Backlog = backlog
}
}
func UDPDataQueueSizeBindOption(size int) BindOption {
return func(opts *BindOptions) {
opts.UDPDataQueueSize = size
}
}
func UDPDataBufferSizeBindOption(size int) BindOption {
return func(opts *BindOptions) {
opts.UDPDataBufferSize = size
}
}
func UDPConnTTLBindOption(ttl time.Duration) BindOption {
return func(opts *BindOptions) {
opts.UDPConnTTL = ttl
}
}