diff --git a/router/consts.go b/router/consts.go deleted file mode 100644 index 6fd11588..00000000 --- a/router/consts.go +++ /dev/null @@ -1,21 +0,0 @@ -package router - -import ( - "math" - "time" -) - -const ( - Port = 6783 - HTTPPort = Port + 1 - MaxUDPPacketSize = 65535 - ChannelSize = 16 - TCPHeartbeat = 30 * time.Second - GossipInterval = 30 * time.Second - MaxDuration = time.Duration(math.MaxInt64) - MaxTCPMsgSize = 10 * 1024 * 1024 - FastHeartbeat = 500 * time.Millisecond - SlowHeartbeat = 10 * time.Second - MaxMissedHeartbeats = 6 - HeartbeatTimeout = MaxMissedHeartbeats * SlowHeartbeat -) diff --git a/router/protocol_crypto.go b/router/protocol_crypto.go index 5fbb48e8..f215a595 100644 --- a/router/protocol_crypto.go +++ b/router/protocol_crypto.go @@ -13,6 +13,8 @@ import ( "golang.org/x/crypto/nacl/secretbox" ) +const MaxTCPMsgSize = 10 * 1024 * 1024 + func GenerateKeyPair() (publicKey, privateKey *[32]byte, err error) { return box.GenerateKey(rand.Reader) } diff --git a/router/router.go b/router/router.go index 9ea3623f..44c3fbdc 100644 --- a/router/router.go +++ b/router/router.go @@ -2,6 +2,7 @@ package router import ( "fmt" + "math" "net" "sync" "time" @@ -10,6 +11,18 @@ import ( ) const ( + Port = 6783 + HTTPPort = Port + 1 + MaxUDPPacketSize = 65535 + ChannelSize = 16 + TCPHeartbeat = 30 * time.Second + GossipInterval = 30 * time.Second + MaxDuration = time.Duration(math.MaxInt64) + FastHeartbeat = 500 * time.Millisecond + SlowHeartbeat = 10 * time.Second + MaxMissedHeartbeats = 6 + HeartbeatTimeout = MaxMissedHeartbeats * SlowHeartbeat + macMaxAge = 10 * time.Minute // [1] acceptMaxTokens = 100 // [2] acceptTokenDelay = 100 * time.Millisecond // [3]