mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
notify inbound tunnels update
This commit is contained in:
parent
eff3bb6ab1
commit
29243fcb47
@ -171,6 +171,7 @@ namespace data
|
|||||||
virtual const uint8_t * GetEncryptionPrivateKey () const = 0;
|
virtual const uint8_t * GetEncryptionPrivateKey () const = 0;
|
||||||
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
||||||
virtual void Sign (const uint8_t * buf, int len, uint8_t * signature) const = 0;
|
virtual void Sign (const uint8_t * buf, int len, uint8_t * signature) const = 0;
|
||||||
|
virtual void SetLeaseSetUpdated () = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ namespace i2p
|
|||||||
const uint8_t * GetEncryptionPrivateKey () const { return GetPrivateKey (); };
|
const uint8_t * GetEncryptionPrivateKey () const { return GetPrivateKey (); };
|
||||||
const uint8_t * GetEncryptionPublicKey () const { return m_Keys.publicKey; };
|
const uint8_t * GetEncryptionPublicKey () const { return m_Keys.publicKey; };
|
||||||
void Sign (const uint8_t * buf, int len, uint8_t * signature) const;
|
void Sign (const uint8_t * buf, int len, uint8_t * signature) const;
|
||||||
|
void SetLeaseSetUpdated () {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -575,22 +575,30 @@ namespace stream
|
|||||||
const i2p::data::LeaseSet * StreamingDestination::GetLeaseSet ()
|
const i2p::data::LeaseSet * StreamingDestination::GetLeaseSet ()
|
||||||
{
|
{
|
||||||
if (!m_Pool) return nullptr;
|
if (!m_Pool) return nullptr;
|
||||||
if (!m_LeaseSet || m_LeaseSet->HasExpiredLeases ())
|
if (!m_LeaseSet)
|
||||||
{
|
UpdateLeaseSet ();
|
||||||
auto newLeaseSet = new i2p::data::LeaseSet (*m_Pool);
|
|
||||||
if (!m_LeaseSet)
|
|
||||||
m_LeaseSet = newLeaseSet;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: implement it better
|
|
||||||
*m_LeaseSet = *newLeaseSet;
|
|
||||||
delete newLeaseSet;
|
|
||||||
}
|
|
||||||
for (auto it: m_Streams)
|
|
||||||
it.second->SetLeaseSetUpdated ();
|
|
||||||
}
|
|
||||||
return m_LeaseSet;
|
return m_LeaseSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StreamingDestination::UpdateLeaseSet ()
|
||||||
|
{
|
||||||
|
auto newLeaseSet = new i2p::data::LeaseSet (*m_Pool);
|
||||||
|
if (!m_LeaseSet)
|
||||||
|
m_LeaseSet = newLeaseSet;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: implement it better
|
||||||
|
*m_LeaseSet = *newLeaseSet;
|
||||||
|
delete newLeaseSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingDestination::SetLeaseSetUpdated ()
|
||||||
|
{
|
||||||
|
UpdateLeaseSet ();
|
||||||
|
for (auto it: m_Streams)
|
||||||
|
it.second->SetLeaseSetUpdated ();
|
||||||
|
}
|
||||||
|
|
||||||
void StreamingDestination::Sign (const uint8_t * buf, int len, uint8_t * signature) const
|
void StreamingDestination::Sign (const uint8_t * buf, int len, uint8_t * signature) const
|
||||||
{
|
{
|
||||||
|
@ -157,10 +157,12 @@ namespace stream
|
|||||||
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
||||||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; };
|
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; };
|
||||||
void Sign (const uint8_t * buf, int len, uint8_t * signature) const;
|
void Sign (const uint8_t * buf, int len, uint8_t * signature) const;
|
||||||
|
void SetLeaseSetUpdated ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Stream * CreateNewIncomingStream ();
|
Stream * CreateNewIncomingStream ();
|
||||||
|
void UpdateLeaseSet ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ namespace tunnel
|
|||||||
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel)
|
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel)
|
||||||
{
|
{
|
||||||
m_InboundTunnels.insert (createdTunnel);
|
m_InboundTunnels.insert (createdTunnel);
|
||||||
|
m_LocalDestination.SetLeaseSetUpdated ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunnelPool::TunnelExpired (InboundTunnel * expiredTunnel)
|
void TunnelPool::TunnelExpired (InboundTunnel * expiredTunnel)
|
||||||
@ -126,6 +127,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
it.second.second->SetState (eTunnelStateFailed);
|
it.second.second->SetState (eTunnelStateFailed);
|
||||||
m_InboundTunnels.erase (it.second.second);
|
m_InboundTunnels.erase (it.second.second);
|
||||||
|
m_LocalDestination.SetLeaseSetUpdated ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
it.second.second->SetState (eTunnelStateTestFailed);
|
it.second.second->SetState (eTunnelStateTestFailed);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user