Skip to content

Commit

Permalink
always pass delivery instructions to tunnel gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Feb 20, 2014
1 parent 154105a commit 345be14
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion NTCPSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace ntcp

#pragma pack()

const int TERMINATION_TIMEOUT = 150; // 2.5 minutes
const int TERMINATION_TIMEOUT = 120; // 2 minutes
class NTCPSession
{
public:
Expand Down
5 changes: 4 additions & 1 deletion TransitTunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ namespace tunnel

void TransitTunnelGateway::SendTunnelDataMsg (i2p::I2NPMessage * msg)
{
m_Gateway.SendTunnelDataMsg (msg);
TunnelMessageBlock block;
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
m_Gateway.SendTunnelDataMsg (block);
}

void TransitTunnelEndpoint::HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg)
Expand Down
17 changes: 16 additions & 1 deletion Tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,22 @@ namespace tunnel

void OutboundTunnel::SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg)
{
m_Gateway.SendTunnelDataMsg (gwHash, gwTunnel, msg);
TunnelMessageBlock block;
if (gwHash)
{
block.hash = gwHash;
if (gwTunnel)
{
block.deliveryType = eDeliveryTypeTunnel;
block.tunnelID = gwTunnel;
}
else
block.deliveryType = eDeliveryTypeRouter;
}
else
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
m_Gateway.SendTunnelDataMsg (block);
}

void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
Expand Down
25 changes: 0 additions & 25 deletions TunnelGateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,6 @@ namespace tunnel
m_TunnelDataMsgs.push_back (m_CurrentTunnelDataMsg);
m_CurrentTunnelDataMsg = nullptr;
}

void TunnelGateway::SendTunnelDataMsg (i2p::I2NPMessage * msg)
{
SendTunnelDataMsg (nullptr, 0, msg);
}

void TunnelGateway::SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg)
{
TunnelMessageBlock block;
if (gwHash)
{
block.hash = gwHash;
if (gwTunnel)
{
block.deliveryType = eDeliveryTypeTunnel;
block.tunnelID = gwTunnel;
}
else
block.deliveryType = eDeliveryTypeRouter;
}
else
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
SendTunnelDataMsg (block);
}

void TunnelGateway::SendTunnelDataMsg (const TunnelMessageBlock& block)
{
Expand Down
2 changes: 0 additions & 2 deletions TunnelGateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ namespace tunnel

TunnelGateway (TunnelBase * tunnel):
m_Tunnel (tunnel), m_Buffer (tunnel->GetNextTunnelID ()), m_NumSentBytes (0) {};
void SendTunnelDataMsg (i2p::I2NPMessage * msg);
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
void SendTunnelDataMsg (const TunnelMessageBlock& block);
void PutTunnelDataMsg (const TunnelMessageBlock& block);
void SendBuffer ();
Expand Down

0 comments on commit 345be14

Please sign in to comment.