]> Cypherpunks.ru repositories - govpn.git/commitdiff
Lock-values are better passed as a pointer
authorSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 12:04:51 +0000 (15:04 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 12:12:52 +0000 (15:12 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
src/govpn/cmd/govpn-client/main.go
src/govpn/cmd/govpn-server/conf.go
src/govpn/identify.go

index 7c4514ef9a92ce163347f646b3085136fed7b45f..c7417f4737a4c265d61e14c93fc290b791656dfa 100644 (file)
@@ -53,7 +53,7 @@ var (
        timeout     int
        firstUpCall bool = true
        knownPeers  govpn.KnownPeers
-       idsCache    govpn.CipherCache
+       idsCache    *govpn.CipherCache
 )
 
 func main() {
index cd746699b4870159dc42b24b3f0e37325ed7da92..6d78d8fc3414f9886a869e1f9b01ebd3430961d5 100644 (file)
@@ -33,7 +33,7 @@ const (
 
 var (
        confs    map[govpn.PeerId]*govpn.PeerConf
-       idsCache govpn.CipherCache
+       idsCache *govpn.CipherCache
 )
 
 func confRead() map[govpn.PeerId]*govpn.PeerConf {
index 89ce6363887b0e276805f69e12bdc7941d0899bb..ed55e0dce6148b540878bf502b821b88d848cd9c 100644 (file)
@@ -46,14 +46,14 @@ type CipherCache struct {
        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{}{}
@@ -81,7 +81,7 @@ func (cc CipherCache) Update(peerIds []PeerId) {
 // 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
        }