mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 17:14:02 +03:00
Make connection multiplexing configurable
This commit is contained in:
@@ -58,6 +58,8 @@ const (
|
||||
|
||||
OptionTypeAntiReplayMaxSize
|
||||
|
||||
OptionTypeMultiplexPerConnection
|
||||
|
||||
OptionTypeSecret
|
||||
OptionTypeAdtag
|
||||
)
|
||||
@@ -80,6 +82,8 @@ type Config struct {
|
||||
|
||||
AntiReplayMaxSize int64 `json:"anti_replay_max_size"`
|
||||
|
||||
MultiplexPerConnection int `json:"multiplex_per_connection"`
|
||||
|
||||
Debug bool `json:"debug"`
|
||||
Verbose bool `json:"verbose"`
|
||||
StatsdTagsFormat statsd.TagFormat `json:"statsd_tags_format"`
|
||||
@@ -149,6 +153,8 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen
|
||||
C.CloakPort = int(opt.Value.(uint16))
|
||||
case OptionTypeAntiReplayMaxSize:
|
||||
C.AntiReplayMaxSize = int64(opt.Value.(units.Base2Bytes))
|
||||
case OptionTypeMultiplexPerConnection:
|
||||
C.MultiplexPerConnection = int(opt.Value.(uint))
|
||||
case OptionTypeSecret:
|
||||
C.Secret = opt.Value.([]byte)
|
||||
case OptionTypeAdtag:
|
||||
@@ -173,6 +179,10 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen
|
||||
return errors.New("incorrect secret")
|
||||
}
|
||||
|
||||
if C.MultiplexPerConnection == 0 {
|
||||
return errors.New("cannot use 0 clients per connection for multiplexing")
|
||||
}
|
||||
|
||||
if C.CloakHost != "" {
|
||||
addrs, err := net.LookupHost(C.CloakHost)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user