Bläddra i källkod

:wrench: Allow to specify max packet size via config file

Also set sane default
Ettore Di Giacinto 3 år sedan
förälder
incheckning
926b05b987
2 ändrade filer med 4 tillägg och 2 borttagningar
  1. 0 1
      cmd/util.go
  2. 4 1
      pkg/edgevpn/options.go

+ 0 - 1
cmd/util.go

@@ -42,7 +42,6 @@ func cliToOpts(c *cli.Context) []edgevpn.Option {
 	return []edgevpn.Option{
 		edgevpn.Logger(llger),
 		edgevpn.LibP2PLogLevel(libp2plvl),
-		edgevpn.MaxMessageSize(2 << 20), // 2MB
 		edgevpn.WithInterfaceMTU(c.Int("mtu")),
 		edgevpn.WithPacketMTU(1420),
 		edgevpn.WithInterfaceAddress(address),

+ 4 - 1
pkg/edgevpn/options.go

@@ -207,6 +207,7 @@ type YAMLConnectionConfig struct {
 	Rendezvous          string `yaml:"rendezvous"`
 	MDNS                string `yaml:"mdns"`
 	MaxBlockChainLength int    `yaml:"max_blockchain_length"`
+	MaxMessageSize      int    `yaml:"max_message_size"`
 }
 
 func (y YAMLConnectionConfig) copy(cfg *Config) {
@@ -224,6 +225,7 @@ func (y YAMLConnectionConfig) copy(cfg *Config) {
 	cfg.ServiceDiscovery = []ServiceDiscovery{d, m}
 	cfg.SealKeyLength = y.OTP.Crypto.Length
 	cfg.MaxBlockChainLength = y.MaxBlockChainLength
+	cfg.MaxMessageSize = y.MaxMessageSize
 }
 
 func GenerateNewConnectionData() (*YAMLConnectionConfig, error) {
@@ -239,7 +241,8 @@ func GenerateNewConnectionData() (*YAMLConnectionConfig, error) {
 	config.OTP.Crypto.Interval = 9000
 	config.OTP.Crypto.Length = 12
 	config.OTP.DHT.Length = 12
-	config.MaxBlockChainLength = 1000
+	config.MaxBlockChainLength = 400
+	config.MaxMessageSize = 20 << 20 // 20MB
 
 	return &config, nil
 }