From e4c696d9669038a57bc4268bccdeca76babda38c Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Mon, 19 Aug 2024 12:45:51 +0200 Subject: [PATCH] chore(p2p): customize defaults Signed-off-by: Ettore Di Giacinto --- core/p2p/p2p.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/core/p2p/p2p.go b/core/p2p/p2p.go index 1a45da23..14dc00f8 100644 --- a/core/p2p/p2p.go +++ b/core/p2p/p2p.go @@ -21,16 +21,40 @@ import ( "github.com/mudler/edgevpn/pkg/protocol" "github.com/mudler/edgevpn/pkg/services" "github.com/mudler/edgevpn/pkg/types" + eutils "github.com/mudler/edgevpn/pkg/utils" "github.com/phayes/freeport" zlog "github.com/rs/zerolog/log" "github.com/mudler/edgevpn/pkg/logger" ) +func generateNewConnectionData() *node.YAMLConnectionConfig { + maxMessSize := 20 << 20 // 20MB + keyLength := 43 + + return &node.YAMLConnectionConfig{ + MaxMessageSize: maxMessSize, + RoomName: eutils.RandStringRunes(keyLength), + Rendezvous: eutils.RandStringRunes(keyLength), + MDNS: eutils.RandStringRunes(keyLength), + OTP: node.OTP{ + DHT: node.OTPConfig{ + Key: eutils.RandStringRunes(keyLength), + Interval: 120, + Length: keyLength, + }, + Crypto: node.OTPConfig{ + Key: eutils.RandStringRunes(keyLength), + Interval: 9000, + Length: keyLength, + }, + }, + } +} + func GenerateToken() string { // Generates a new config and exit - newData := node.GenerateNewConnectionData(120) - return newData.Base64() + return generateNewConnectionData().Base64() } func IsP2PEnabled() bool {