1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-02-02 06:54:15 +00:00

don't create non-accepted transit tunnel

This commit is contained in:
orignal 2014-09-30 22:08:05 -04:00
parent 6fd5db250b
commit 51d09b788b

View File

@ -287,7 +287,10 @@ namespace i2p
LogPrint ("Record ",i," is ours"); LogPrint ("Record ",i," is ours");
i2p::crypto::ElGamalDecrypt (i2p::context.GetPrivateKey (), records[i].encrypted, (uint8_t *)&clearText); i2p::crypto::ElGamalDecrypt (i2p::context.GetPrivateKey (), records[i].encrypted, (uint8_t *)&clearText);
// replace record to reply
I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i);
if (i2p::context.AcceptsTunnels ())
{
i2p::tunnel::TransitTunnel * transitTunnel = i2p::tunnel::TransitTunnel * transitTunnel =
i2p::tunnel::CreateTransitTunnel ( i2p::tunnel::CreateTransitTunnel (
be32toh (clearText.receiveTunnel), be32toh (clearText.receiveTunnel),
@ -295,9 +298,11 @@ namespace i2p
clearText.layerKey, clearText.ivKey, clearText.layerKey, clearText.ivKey,
clearText.flag & 0x80, clearText.flag & 0x40); clearText.flag & 0x80, clearText.flag & 0x40);
i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel); i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel);
// replace record to reply reply->ret = 0;
I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i); }
reply->ret = i2p::context.AcceptsTunnels () ? 0 : 30; // always reject with bandwidth reason (30) else
reply->ret = 30; // always reject with bandwidth reason (30)
//TODO: fill filler //TODO: fill filler
CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret
// encrypt reply // encrypt reply