mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-17 21:26:04 +00:00
save peer test nonces
This commit is contained in:
parent
5099b997ad
commit
d09bafa4a7
37
SSU.cpp
37
SSU.cpp
@ -733,19 +733,40 @@ namespace ssu
|
|||||||
uint16_t port = *(uint16_t *)buf; // use it as is
|
uint16_t port = *(uint16_t *)buf; // use it as is
|
||||||
buf += 2; // port
|
buf += 2; // port
|
||||||
uint8_t * introKey = buf;
|
uint8_t * introKey = buf;
|
||||||
if (port)
|
if (port && !address)
|
||||||
{
|
{
|
||||||
LogPrint ("SSU peer test. We are Charlie");
|
LogPrint ("Address of ", size, " bytes not supported");
|
||||||
Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob
|
return;
|
||||||
if (address)
|
}
|
||||||
SendPeerTest (nonce, be32toh (*(uint32_t *)address), be16toh (port), introKey); // to Alice
|
if (m_PeerTestNonces.count (nonce) > 0)
|
||||||
|
{
|
||||||
|
// existing test
|
||||||
|
if (port)
|
||||||
|
{
|
||||||
|
LogPrint ("SSU peer test from Charlie. We are Bob");
|
||||||
|
// TODO: back to Alice
|
||||||
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("Address of ", size, " bytes not supported");
|
{
|
||||||
|
LogPrint ("SSU peer test from Alice. We are Charlie");
|
||||||
|
SendPeerTest (nonce, be32toh (*(uint32_t *)address), be16toh (port), introKey); // to Alice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("SSU peer test. We are Bob");
|
// new test
|
||||||
// TODO:
|
m_PeerTestNonces.insert (nonce);
|
||||||
|
if (port)
|
||||||
|
{
|
||||||
|
LogPrint ("SSU peer test from Bob. We are Charlie");
|
||||||
|
Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob
|
||||||
|
SendPeerTest (nonce, be32toh (*(uint32_t *)address), be16toh (port), introKey); // to Alice
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint ("SSU peer test from Alice. We are Bob");
|
||||||
|
// TODO: find Charlie
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
SSU.h
2
SSU.h
@ -4,6 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <set>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cryptopp/modes.h>
|
#include <cryptopp/modes.h>
|
||||||
#include <cryptopp/aes.h>
|
#include <cryptopp/aes.h>
|
||||||
@ -131,6 +132,7 @@ namespace ssu
|
|||||||
bool m_PeerTest;
|
bool m_PeerTest;
|
||||||
SessionState m_State;
|
SessionState m_State;
|
||||||
uint32_t m_RelayTag;
|
uint32_t m_RelayTag;
|
||||||
|
std::set<uint32_t> m_PeerTestNonces;
|
||||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption m_Encryption;
|
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption m_Encryption;
|
||||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption m_Decryption;
|
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption m_Decryption;
|
||||||
uint8_t m_SessionKey[32], m_MacKey[32];
|
uint8_t m_SessionKey[32], m_MacKey[32];
|
||||||
|
Loading…
Reference in New Issue
Block a user