Browse Source

select proper SSU address for incoming sessions

pull/106/head
orignal 10 years ago
parent
commit
54ec71d30d
  1. 9
      RouterInfo.cpp
  2. 3
      RouterInfo.h
  3. 3
      SSU.cpp

9
RouterInfo.cpp

@ -625,13 +625,18 @@ namespace data @@ -625,13 +625,18 @@ namespace data
return GetAddress (eTransportSSU, v4only);
}
const RouterInfo::Address * RouterInfo::GetAddress (TransportStyle s, bool v4only) const
const RouterInfo::Address * RouterInfo::GetSSUV6Address () const
{
return GetAddress (eTransportSSU, false, true);
}
const RouterInfo::Address * RouterInfo::GetAddress (TransportStyle s, bool v4only, bool v6only) const
{
for (auto& address : m_Addresses)
{
if (address.transportStyle == s)
{
if (!v4only || address.host.is_v4 ())
if ((!v4only || address.host.is_v4 ()) && (!v6only || address.host.is_v6 ()))
return &address;
}
}

3
RouterInfo.h

@ -98,6 +98,7 @@ namespace data @@ -98,6 +98,7 @@ namespace data
std::vector<Address>& GetAddresses () { return m_Addresses; };
const Address * GetNTCPAddress (bool v4only = true) const;
const Address * GetSSUAddress (bool v4only = true) const;
const Address * GetSSUV6Address () const;
void AddNTCPAddress (const char * host, int port);
void AddSSUAddress (const char * host, int port, const uint8_t * key);
@ -152,7 +153,7 @@ namespace data @@ -152,7 +153,7 @@ namespace data
size_t ReadString (char * str, std::istream& s);
void WriteString (const std::string& str, std::ostream& s);
void ExtractCaps (const char * value);
const Address * GetAddress (TransportStyle s, bool v4only) const;
const Address * GetAddress (TransportStyle s, bool v4only, bool v6only = false) const;
void UpdateCapsProperty ();
private:

3
SSU.cpp

@ -327,7 +327,8 @@ namespace transport @@ -327,7 +327,8 @@ namespace transport
void SSUSession::SendSessionCreated (const uint8_t * x)
{
auto introKey = GetIntroKey ();
auto address = i2p::context.GetRouterInfo ().GetSSUAddress ();
auto address = IsV6 () ? i2p::context.GetRouterInfo ().GetSSUV6Address () :
i2p::context.GetRouterInfo ().GetSSUAddress (true); //v4 only
if (!introKey || !address)
{
LogPrint (eLogError, "SSU is not supported");

Loading…
Cancel
Save