mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
correct endianess for PeerTest mesaage connection id
This commit is contained in:
parent
2a5cf3e4a8
commit
e4d5788cdc
|
@ -115,7 +115,7 @@ namespace transport
|
||||||
payloadSize += CreatePaddingBlock (payload + payloadSize, SSU2_MAX_PAYLOAD_SIZE - payloadSize);
|
payloadSize += CreatePaddingBlock (payload + payloadSize, SSU2_MAX_PAYLOAD_SIZE - payloadSize);
|
||||||
// send
|
// send
|
||||||
m_RelaySessions.emplace (nonce, std::make_pair (session, ts));
|
m_RelaySessions.emplace (nonce, std::make_pair (session, ts));
|
||||||
session->m_SourceConnID = htobe64 (((uint64_t)nonce << 32) | nonce);
|
session->m_SourceConnID = ((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce);
|
||||||
session->m_DestConnID = ~session->m_SourceConnID;
|
session->m_DestConnID = ~session->m_SourceConnID;
|
||||||
m_Server.AddSession (session);
|
m_Server.AddSession (session);
|
||||||
SendData (payload, payloadSize);
|
SendData (payload, payloadSize);
|
||||||
|
@ -139,7 +139,7 @@ namespace transport
|
||||||
auto session = std::make_shared<SSU2Session> (m_Server);
|
auto session = std::make_shared<SSU2Session> (m_Server);
|
||||||
session->SetState (eSSU2SessionStatePeerTest);
|
session->SetState (eSSU2SessionStatePeerTest);
|
||||||
m_PeerTests.emplace (nonce, std::make_pair (session, ts));
|
m_PeerTests.emplace (nonce, std::make_pair (session, ts));
|
||||||
session->m_SourceConnID = htobe64 (((uint64_t)nonce << 32) | nonce);
|
session->m_SourceConnID = ((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce);
|
||||||
session->m_DestConnID = ~session->m_SourceConnID;
|
session->m_DestConnID = ~session->m_SourceConnID;
|
||||||
m_Server.AddSession (session);
|
m_Server.AddSession (session);
|
||||||
// peer test block
|
// peer test block
|
||||||
|
@ -833,7 +833,7 @@ namespace transport
|
||||||
Header header;
|
Header header;
|
||||||
uint8_t h[32], payload[SSU2_MAX_PAYLOAD_SIZE];
|
uint8_t h[32], payload[SSU2_MAX_PAYLOAD_SIZE];
|
||||||
// fill packet
|
// fill packet
|
||||||
header.h.connID = htobe64 (((uint64_t)nonce << 32) | nonce); // dest id
|
header.h.connID = ((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce); // dest id
|
||||||
RAND_bytes (header.buf + 8, 4); // random packet num
|
RAND_bytes (header.buf + 8, 4); // random packet num
|
||||||
header.h.type = eSSU2HolePunch;
|
header.h.type = eSSU2HolePunch;
|
||||||
header.h.flags[0] = 2; // ver
|
header.h.flags[0] = 2; // ver
|
||||||
|
@ -1470,7 +1470,7 @@ namespace transport
|
||||||
auto session = std::make_shared<SSU2Session> (m_Server, r, addr);
|
auto session = std::make_shared<SSU2Session> (m_Server, r, addr);
|
||||||
session->SetState (eSSU2SessionStatePeerTest);
|
session->SetState (eSSU2SessionStatePeerTest);
|
||||||
session->m_RemoteEndpoint = ep; // might be different
|
session->m_RemoteEndpoint = ep; // might be different
|
||||||
session->m_DestConnID = htobe64 (((uint64_t)nonce << 32) | nonce);
|
session->m_DestConnID = ((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce);
|
||||||
session->m_SourceConnID = ~session->m_SourceConnID;
|
session->m_SourceConnID = ~session->m_SourceConnID;
|
||||||
m_Server.AddSession (session);
|
m_Server.AddSession (session);
|
||||||
session->SendPeerTest (5, buf + 35, len - 35, addr->i);
|
session->SendPeerTest (5, buf + 35, len - 35, addr->i);
|
||||||
|
@ -1547,7 +1547,7 @@ namespace transport
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5: // Alice from Charlie 1
|
case 5: // Alice from Charlie 1
|
||||||
if (htobe64 (((uint64_t)nonce << 32) | nonce) == m_SourceConnID)
|
if ((((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce)) == m_SourceConnID)
|
||||||
{
|
{
|
||||||
if (m_Address)
|
if (m_Address)
|
||||||
SendPeerTest (6, buf + 3, len - 3, m_Address->i);
|
SendPeerTest (6, buf + 3, len - 3, m_Address->i);
|
||||||
|
@ -1563,10 +1563,10 @@ namespace transport
|
||||||
SendPeerTest (7, buf + 3, len - 3, m_Address->i);
|
SendPeerTest (7, buf + 3, len - 3, m_Address->i);
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "SSU2: Unknown addrees for peer test 6");
|
LogPrint (eLogWarning, "SSU2: Unknown addrees for peer test 6");
|
||||||
m_Server.RemoveSession (~htobe64 (((uint64_t)nonce << 32) | nonce));
|
m_Server.RemoveSession (~(((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce)));
|
||||||
break;
|
break;
|
||||||
case 7: // Alice from Charlie 2
|
case 7: // Alice from Charlie 2
|
||||||
m_Server.RemoveSession (htobe64 (((uint64_t)nonce << 32) | nonce));
|
m_Server.RemoveSession (((uint64_t)htobe32 (nonce) << 32) | htobe32 (nonce));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogWarning, "SSU2: PeerTest unexpected msg num ", buf[0]);
|
LogPrint (eLogWarning, "SSU2: PeerTest unexpected msg num ", buf[0]);
|
||||||
|
|
Loading…
Reference in a new issue