var (
confs map[govpn.PeerId]*govpn.PeerConf
- idsCache govpn.CipherCache
+ idsCache *govpn.CipherCache
)
func confRead() map[govpn.PeerId]*govpn.PeerConf {
l sync.RWMutex
}
-func NewCipherCache(peerIds []PeerId) CipherCache {
+func NewCipherCache(peerIds []PeerId) *CipherCache {
cc := CipherCache{c: make(map[PeerId]*xtea.Cipher, len(peerIds))}
cc.Update(peerIds)
- return cc
+ return &cc
}
// Remove disappeared keys, add missing ones with initialized ciphers.
-func (cc CipherCache) Update(peerIds []PeerId) {
+func (cc *CipherCache) Update(peerIds []PeerId) {
available := make(map[PeerId]struct{})
for _, peerId := range peerIds {
available[peerId] = struct{}{}
// Try to find peer's identity (that equals to an encryption key)
// by taking first blocksize sized bytes from data at the beginning
// as plaintext and last bytes as cyphertext.
-func (cc CipherCache) Find(data []byte) *PeerId {
+func (cc *CipherCache) Find(data []byte) *PeerId {
if len(data) < xtea.BlockSize*2 {
return nil
}