dht.NewServer: Initialize the tokenServer

This commit is contained in:
Matt Joiner 2016-11-27 02:22:47 +11:00
parent 4a7fbf6170
commit 79310dd264
1 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package dht
import (
"crypto"
"crypto/rand"
"encoding/binary"
"encoding/hex"
"errors"
@ -79,7 +80,13 @@ func NewServer(c *ServerConfig) (s *Server, err error) {
config: *c,
ipBlockList: c.IPBlocklist,
badNodes: boom.NewBloomFilter(1000, 0.1),
tokenServer: tokenServer{
maxIntervalDelta: 2,
interval: 5 * time.Minute,
secret: make([]byte, 20),
},
}
rand.Read(s.tokenServer.secret)
if c.Conn != nil {
s.socket = c.Conn
} else {