Skip to content

Commit e4c696d

Browse files
committed
chore(p2p): customize defaults
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent d58f9c3 commit e4c696d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

core/p2p/p2p.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,40 @@ import (
2121
"github.com/mudler/edgevpn/pkg/protocol"
2222
"github.com/mudler/edgevpn/pkg/services"
2323
"github.com/mudler/edgevpn/pkg/types"
24+
eutils "github.com/mudler/edgevpn/pkg/utils"
2425
"github.com/phayes/freeport"
2526
zlog "github.com/rs/zerolog/log"
2627

2728
"github.com/mudler/edgevpn/pkg/logger"
2829
)
2930

31+
func generateNewConnectionData() *node.YAMLConnectionConfig {
32+
maxMessSize := 20 << 20 // 20MB
33+
keyLength := 43
34+
35+
return &node.YAMLConnectionConfig{
36+
MaxMessageSize: maxMessSize,
37+
RoomName: eutils.RandStringRunes(keyLength),
38+
Rendezvous: eutils.RandStringRunes(keyLength),
39+
MDNS: eutils.RandStringRunes(keyLength),
40+
OTP: node.OTP{
41+
DHT: node.OTPConfig{
42+
Key: eutils.RandStringRunes(keyLength),
43+
Interval: 120,
44+
Length: keyLength,
45+
},
46+
Crypto: node.OTPConfig{
47+
Key: eutils.RandStringRunes(keyLength),
48+
Interval: 9000,
49+
Length: keyLength,
50+
},
51+
},
52+
}
53+
}
54+
3055
func GenerateToken() string {
3156
// Generates a new config and exit
32-
newData := node.GenerateNewConnectionData(120)
33-
return newData.Base64()
57+
return generateNewConnectionData().Base64()
3458
}
3559

3660
func IsP2PEnabled() bool {

0 commit comments

Comments
 (0)