Skip to content

Commit

Permalink
recreate router.info if missing or malformed
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Apr 5, 2016
1 parent 97afa50 commit f48a7df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions RouterContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,24 @@ namespace i2p
delete[] buf;
}

i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO)); // TODO
m_RouterInfo.SetRouterIdentity (GetIdentity ());
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
m_RouterInfo.SetProperty ("coreVersion", I2P_VERSION);
m_RouterInfo.SetProperty ("router.version", I2P_VERSION);
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO));
if (!routerInfo.IsUnreachable ()) // router.info looks good
{
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
m_RouterInfo.SetProperty ("coreVersion", I2P_VERSION);
m_RouterInfo.SetProperty ("router.version", I2P_VERSION);

// Migration to 0.9.24. TODO: remove later
m_RouterInfo.DeleteProperty ("coreVersion");
m_RouterInfo.DeleteProperty ("stat_uptime");
}
else
{
LogPrint (eLogError, ROUTER_INFO, " is malformed. Creating new");
NewRouterInfo ();
}

// Migration to 0.9.24. TODO: remove later
m_RouterInfo.DeleteProperty ("coreVersion");
m_RouterInfo.DeleteProperty ("stat_uptime");

if (IsUnreachable ())
SetReachable (); // we assume reachable until we discover firewall through peer tests

Expand Down
2 changes: 2 additions & 0 deletions RouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ namespace data
{
if (LoadFile ())
ReadFromBuffer (false);
else
m_IsUnreachable = true;
}

void RouterInfo::ReadFromBuffer (bool verifySignature)
Expand Down

0 comments on commit f48a7df

Please sign in to comment.