refactor: remove last dependency of crypto on LocalConnection

This commit is contained in:
Matthias Radestock committed 2015-04-27 07:27:31 +01:00
1 parent ea4e84cdd3
commit 02a7875eb8
2 files changed
+11 -7

No files matched your search

+6 -2
View File
@@ -30,8 +30,8 @@ func (conn *LocalConnection) ensureForwarders() error {
usingPassword := conn.SessionKey != nil
var encryptor, encryptorDF Encryptor
if usingPassword {
encryptor = NewNaClEncryptor(conn.local.NameByte, conn, conn.SessionKey, false)
encryptorDF = NewNaClEncryptor(conn.local.NameByte, conn, conn.SessionKey, true)
encryptor = NewNaClEncryptor(conn.local.NameByte, conn.SessionKey, conn.sendNonce, false)
encryptorDF = NewNaClEncryptor(conn.local.NameByte, conn.SessionKey, conn.sendNonce, true)
} else {
encryptor = NewNonEncryptor(conn.local.NameByte)
encryptorDF = NewNonEncryptor(conn.local.NameByte)
@@ -62,6 +62,10 @@ func (conn *LocalConnection) stopForwarders() {
conn.forwarderDF.Shutdown()
}
func (conn *LocalConnection) sendNonce(encodedNonce []byte) {
conn.SendProtocolMsg(ProtocolMsg{ProtocolNonce, encodedNonce})
}
// Called from peer.Relay[Broadcast] which is itself invoked from
// router (both UDP listener process and sniffer process). Also called
// from connection's heartbeat process, and from the connection's TCP