diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-27 17:33:06 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-27 17:33:06 +0200 |
commit | 8236f3afa2eca0aae6c5da9560301c04d882c81b (patch) | |
tree | 5babaff66d6709f7f1fcdba69847ac684d1ef3de /src/device.go | |
parent | eb75ff430d1f78e129bbfe49d612f241ca418df4 (diff) | |
download | wireguard-go-8236f3afa2eca0aae6c5da9560301c04d882c81b.tar.gz wireguard-go-8236f3afa2eca0aae6c5da9560301c04d882c81b.zip |
Implemented MAC1/2 calculation
Diffstat (limited to 'src/device.go')
-rw-r--r-- | src/device.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/device.go b/src/device.go index 4b8cda0..b3484c5 100644 --- a/src/device.go +++ b/src/device.go @@ -1,25 +1,24 @@ package main import ( - "log" "net" "sync" ) type Device struct { mtu int - source *net.UDPAddr // UDP source address + fwMark uint32 + address *net.UDPAddr // UDP source address conn *net.UDPConn // UDP "connection" mutex sync.RWMutex - peers map[NoisePublicKey]*Peer - indices IndexTable privateKey NoisePrivateKey publicKey NoisePublicKey - fwMark uint32 - listenPort uint16 routingTable RoutingTable - logger log.Logger + indices IndexTable + log *Logger queueWorkOutbound chan *OutboundWorkQueueElement + peers map[NoisePublicKey]*Peer + mac MacStateDevice } func (device *Device) SetPrivateKey(sk NoisePrivateKey) { @@ -30,8 +29,9 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) { device.privateKey = sk device.publicKey = sk.publicKey() + device.mac.Init(device.publicKey) - // do precomputations + // do DH precomputations for _, peer := range device.peers { h := &peer.handshake @@ -45,9 +45,9 @@ func (device *Device) Init() { device.mutex.Lock() defer device.mutex.Unlock() + device.log = NewLogger() device.peers = make(map[NoisePublicKey]*Peer) device.indices.Init() - device.listenPort = 0 device.routingTable.Reset() } |