From 51d09b788b6a5ed584b633c30a65f778ebceee2a Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 30 Sep 2014 22:08:05 -0400 Subject: [PATCH] don't create non-accepted transit tunnel --- I2NPProtocol.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index d0c2e50c..43167687 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -287,17 +287,22 @@ namespace i2p LogPrint ("Record ",i," is ours"); i2p::crypto::ElGamalDecrypt (i2p::context.GetPrivateKey (), records[i].encrypted, (uint8_t *)&clearText); - - i2p::tunnel::TransitTunnel * transitTunnel = - i2p::tunnel::CreateTransitTunnel ( - be32toh (clearText.receiveTunnel), - clearText.nextIdent, be32toh (clearText.nextTunnel), - clearText.layerKey, clearText.ivKey, - clearText.flag & 0x80, clearText.flag & 0x40); - i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel); // replace record to reply - I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i); - reply->ret = i2p::context.AcceptsTunnels () ? 0 : 30; // always reject with bandwidth reason (30) + I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i); + if (i2p::context.AcceptsTunnels ()) + { + i2p::tunnel::TransitTunnel * transitTunnel = + i2p::tunnel::CreateTransitTunnel ( + be32toh (clearText.receiveTunnel), + clearText.nextIdent, be32toh (clearText.nextTunnel), + clearText.layerKey, clearText.ivKey, + clearText.flag & 0x80, clearText.flag & 0x40); + i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel); + reply->ret = 0; + } + else + reply->ret = 30; // always reject with bandwidth reason (30) + //TODO: fill filler CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret // encrypt reply