@ -272,7 +272,8 @@ namespace client
if ( ! m_Pool ) return nullptr ;
if ( ! m_Pool ) return nullptr ;
if ( ! m_LeaseSet )
if ( ! m_LeaseSet )
UpdateLeaseSet ( ) ;
UpdateLeaseSet ( ) ;
return GetLeaseSetMt ( ) ;
auto ls = GetLeaseSetMt ( ) ;
return ( ls & & ls - > GetInnerLeaseSet ( ) ) ? ls - > GetInnerLeaseSet ( ) : ls ; // always non-encrypted
}
}
std : : shared_ptr < const i2p : : data : : LocalLeaseSet > LeaseSetDestination : : GetLeaseSetMt ( )
std : : shared_ptr < const i2p : : data : : LocalLeaseSet > LeaseSetDestination : : GetLeaseSetMt ( )
@ -592,27 +593,31 @@ namespace client
{
{
if ( ecode ! = boost : : asio : : error : : operation_aborted )
if ( ecode ! = boost : : asio : : error : : operation_aborted )
{
{
auto ls = GetLeaseSetMt ( ) ;
if ( ! ls )
{
LogPrint ( eLogWarning , " Destination: couldn't verify LeaseSet for " , GetIdentHash ( ) . ToBase32 ( ) ) ;
return ;
}
auto s = shared_from_this ( ) ;
auto s = shared_from_this ( ) ;
RequestLeaseSet ( GetIdentHash ( ) ,
RequestLeaseSet ( ls - > GetStoreHash ( ) ,
// "this" added due to bug in gcc 4.7-4.8
[ s , ls ] ( std : : shared_ptr < const i2p : : data : : LeaseSet > leaseSet )
[ s , this ] ( std : : shared_ptr < const i2p : : data : : LeaseSet > leaseSet )
{
{
if ( leaseSet )
if ( leaseSet )
{
{
auto ls = s - > GetLeaseSetMt ( ) ;
if ( * ls = = * leaseSet )
if ( ls & & * ls = = * leaseSet )
{
{
// we got latest LeasetSet
// we got latest LeasetSet
LogPrint ( eLogDebug , " Destination: published LeaseSet verified for " , GetIdentHash ( ) . ToBase32 ( ) ) ;
LogPrint ( eLogDebug , " Destination: published LeaseSet verified for " , s - > GetIdentHash ( ) . ToBase32 ( ) ) ;
s - > m_PublishVerificationTimer . expires_from_now ( boost : : posix_time : : seconds ( PUBLISH_REGULAR_VERIFICATION_INTERNAL ) ) ;
s - > m_PublishVerificationTimer . expires_from_now ( boost : : posix_time : : seconds ( PUBLISH_REGULAR_VERIFICATION_INTERNAL ) ) ;
s - > m_PublishVerificationTimer . async_wait ( std : : bind ( & LeaseSetDestination : : HandlePublishVerificationTimer , s , std : : placeholders : : _1 ) ) ;
s - > m_PublishVerificationTimer . async_wait ( std : : bind ( & LeaseSetDestination : : HandlePublishVerificationTimer , s , std : : placeholders : : _1 ) ) ;
return ;
return ;
}
}
else
else
LogPrint ( eLogDebug , " Destination: LeaseSet is different than just published for " , GetIdentHash ( ) . ToBase32 ( ) ) ;
LogPrint ( eLogDebug , " Destination: LeaseSet is different than just published for " , s - > GetIdentHash ( ) . ToBase32 ( ) ) ;
}
}
else
else
LogPrint ( eLogWarning , " Destination: couldn't find published LeaseSet for " , GetIdentHash ( ) . ToBase32 ( ) ) ;
LogPrint ( eLogWarning , " Destination: couldn't find published LeaseSet for " , s - > GetIdentHash ( ) . ToBase32 ( ) ) ;
// we have to publish again
// we have to publish again
s - > Publish ( ) ;
s - > Publish ( ) ;
} ) ;
} ) ;
@ -1121,10 +1126,13 @@ namespace client
}
}
else
else
{
{
// standard LS2 (type 3) assumed for now. TODO: implement othe rs
// standard LS2 (type 3) first
auto keyLen = m_Decryptor ? m_Decryptor - > GetPublicKeyLen ( ) : 256 ;
auto keyLen = m_Decryptor ? m_Decryptor - > GetPublicKeyLen ( ) : 256 ;
leaseSet = std : : make_shared < i2p : : data : : LocalLeaseSet2 > ( i2p : : data : : NETDB_STORE_TYPE_STANDARD_LEASESET2 ,
auto ls2 = std : : make_shared < i2p : : data : : LocalLeaseSet2 > ( i2p : : data : : NETDB_STORE_TYPE_STANDARD_LEASESET2 ,
m_Keys , m_EncryptionKeyType , keyLen , m_EncryptionPublicKey , tunnels ) ;
m_Keys , m_EncryptionKeyType , keyLen , m_EncryptionPublicKey , tunnels ) ;
if ( GetLeaseSetType ( ) = = i2p : : data : : NETDB_STORE_TYPE_ENCRYPTED_LEASESET2 ) // encrypt if type 5
ls2 = std : : make_shared < i2p : : data : : LocalEncryptedLeaseSet2 > ( ls2 , m_Keys ) ;
leaseSet = ls2 ;
}
}
SetLeaseSet ( leaseSet ) ;
SetLeaseSet ( leaseSet ) ;
}
}