|
|
@ -14,8 +14,8 @@ namespace i2p |
|
|
|
namespace tunnel |
|
|
|
namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Tunnel::Tunnel (TunnelConfig * config): m_Config (config), m_Pool (nullptr), |
|
|
|
Tunnel::Tunnel (TunnelConfig * config): |
|
|
|
m_IsEstablished (false), m_IsFailed (false) |
|
|
|
m_Config (config), m_Pool (nullptr), m_State (eTunnelStatePending) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ namespace tunnel |
|
|
|
hop = hop->prev; |
|
|
|
hop = hop->prev; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_IsEstablished = true; |
|
|
|
bool established = true; |
|
|
|
hop = m_Config->GetFirstHop (); |
|
|
|
hop = m_Config->GetFirstHop (); |
|
|
|
while (hop) |
|
|
|
while (hop) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -119,10 +119,10 @@ namespace tunnel |
|
|
|
LogPrint ("Ret code=", (int)record->ret); |
|
|
|
LogPrint ("Ret code=", (int)record->ret); |
|
|
|
if (record->ret) |
|
|
|
if (record->ret) |
|
|
|
// if any of participants declined the tunnel is not established
|
|
|
|
// if any of participants declined the tunnel is not established
|
|
|
|
m_IsEstablished = false; |
|
|
|
established = false; |
|
|
|
hop = hop->next; |
|
|
|
hop = hop->next; |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_IsEstablished) |
|
|
|
if (established) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// change reply keys to layer keys
|
|
|
|
// change reply keys to layer keys
|
|
|
|
hop = m_Config->GetFirstHop (); |
|
|
|
hop = m_Config->GetFirstHop (); |
|
|
@ -132,7 +132,8 @@ namespace tunnel |
|
|
|
hop = hop->next; |
|
|
|
hop = hop->next; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return m_IsEstablished; |
|
|
|
if (established) m_State = eTunnelStateEstablished; |
|
|
|
|
|
|
|
return established; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Tunnel::EncryptTunnelMsg (I2NPMessage * tunnelMsg) |
|
|
|
void Tunnel::EncryptTunnelMsg (I2NPMessage * tunnelMsg) |
|
|
@ -148,7 +149,7 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
void InboundTunnel::HandleTunnelDataMsg (I2NPMessage * msg) |
|
|
|
void InboundTunnel::HandleTunnelDataMsg (I2NPMessage * msg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IsFailed ()) SetFailed (false); // incoming messages means a tunnel is alive
|
|
|
|
if (IsFailed ()) SetState (eTunnelStateEstablished); // incoming messages means a tunnel is alive
|
|
|
|
msg->from = this; |
|
|
|
msg->from = this; |
|
|
|
EncryptTunnelMsg (msg); |
|
|
|
EncryptTunnelMsg (msg); |
|
|
|
m_Endpoint.HandleDecryptedTunnelDataMsg (msg); |
|
|
|
m_Endpoint.HandleDecryptedTunnelDataMsg (msg); |
|
|
|