X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fpeer.go;h=37bd8405182afea9f205afd2782c1dbd9b97593e;hb=30697303bd8e3a2489627962252928bc125ff472;hp=792ebe7d7e1606adc0b1d8737db5ff1e7643ca9e;hpb=18d0c712f6954564df50e5aa78862b1d6e128b3b;p=govpn.git diff --git a/src/cypherpunks.ru/govpn/peer.go b/src/cypherpunks.ru/govpn/peer.go index 792ebe7..37bd840 100644 --- a/src/cypherpunks.ru/govpn/peer.go +++ b/src/cypherpunks.ru/govpn/peer.go @@ -63,10 +63,8 @@ func newNonces(key *[32]byte, i uint64) chan *[NonceSize]byte { buf := new([NonceSize]byte) binary.BigEndian.PutUint64(buf[:], i) mac.Write(buf[:]) - sum = mac.Sum(nil) - for index := 0; index < NonceSize; index++ { - buf[index] = sum[index] - } + mac.Sum(sum[:0]) + copy(buf[:], sum) nonces <- buf mac.Reset() i += 2 @@ -90,7 +88,7 @@ type Peer struct { // Basic Addr string - Id *PeerId + ID *PeerID Conn io.Writer `json:"-"` // Traffic behaviour @@ -100,7 +98,7 @@ type Peer struct { Encless bool MTU int - key *[SSize]byte `json:"-"` + key *[SSize]byte // Timers Timeout time.Duration `json:"-"` @@ -137,7 +135,7 @@ type Peer struct { } func (p *Peer) String() string { - return p.Id.String() + ":" + p.Addr + return p.ID.String() + ":" + p.Addr } // Zero peer's memory state. @@ -187,7 +185,7 @@ func newPeer(isClient bool, addr string, conn io.Writer, conf *PeerConf, key *[S peer := Peer{ Addr: addr, - Id: conf.Id, + ID: conf.ID, Conn: conn, NoiseEnable: noiseEnable,