mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-29 12:17:49 +02:00
Logging: finish capitalization fixups
This commit is contained in:
parent
cc1e8e3dcf
commit
789a31e16d
23 changed files with 700 additions and 700 deletions
|
@ -389,7 +389,7 @@ namespace util
|
||||||
LogPrint(eLogInfo, "Daemon: Transports started");
|
LogPrint(eLogInfo, "Daemon: Transports started");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Daemon: Failed to start transports");
|
LogPrint(eLogError, "Daemon: Failed to start Transports");
|
||||||
/** shut down netdb right away */
|
/** shut down netdb right away */
|
||||||
i2p::transport::transports.Stop();
|
i2p::transport::transports.Stop();
|
||||||
i2p::data::netdb.Stop();
|
i2p::data::netdb.Stop();
|
||||||
|
@ -400,7 +400,7 @@ namespace util
|
||||||
if (http) {
|
if (http) {
|
||||||
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
||||||
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
|
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
|
||||||
LogPrint(eLogInfo, "Daemon: Starting webconsole at ", httpAddr, ":", httpPort);
|
LogPrint(eLogInfo, "Daemon: Starting Webconsole at ", httpAddr, ":", httpPort);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort));
|
d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort));
|
||||||
|
@ -408,16 +408,16 @@ namespace util
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Daemon: Failed to start webconsole: ", ex.what ());
|
LogPrint (eLogError, "Daemon: Failed to start Webconsole: ", ex.what ());
|
||||||
ThrowFatal ("Unable to start webconsole at ", httpAddr, ":", httpPort, ": ", ex.what ());
|
ThrowFatal ("Unable to start webconsole at ", httpAddr, ":", httpPort, ": ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LogPrint(eLogInfo, "Daemon: Starting tunnels");
|
LogPrint(eLogInfo, "Daemon: Starting Tunnels");
|
||||||
i2p::tunnel::tunnels.Start();
|
i2p::tunnel::tunnels.Start();
|
||||||
|
|
||||||
LogPrint(eLogInfo, "Daemon: Starting client");
|
LogPrint(eLogInfo, "Daemon: Starting Client");
|
||||||
i2p::client::context.Start ();
|
i2p::client::context.Start ();
|
||||||
|
|
||||||
// I2P Control Protocol
|
// I2P Control Protocol
|
||||||
|
@ -443,9 +443,9 @@ namespace util
|
||||||
bool Daemon_Singleton::stop()
|
bool Daemon_Singleton::stop()
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo, "Daemon: Shutting down");
|
LogPrint(eLogInfo, "Daemon: Shutting down");
|
||||||
LogPrint(eLogInfo, "Daemon: Stopping client");
|
LogPrint(eLogInfo, "Daemon: Stopping Client");
|
||||||
i2p::client::context.Stop();
|
i2p::client::context.Stop();
|
||||||
LogPrint(eLogInfo, "Daemon: Stopping tunnels");
|
LogPrint(eLogInfo, "Daemon: Stopping Tunnels");
|
||||||
i2p::tunnel::tunnels.Stop();
|
i2p::tunnel::tunnels.Stop();
|
||||||
|
|
||||||
if (d.UPnP)
|
if (d.UPnP)
|
||||||
|
@ -460,7 +460,7 @@ namespace util
|
||||||
d.m_NTPSync = nullptr;
|
d.m_NTPSync = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint(eLogInfo, "Daemon: Stopping transports");
|
LogPrint(eLogInfo, "Daemon: Stopping Transports");
|
||||||
i2p::transport::transports.Stop();
|
i2p::transport::transports.Stop();
|
||||||
LogPrint(eLogInfo, "Daemon: Stopping NetDB");
|
LogPrint(eLogInfo, "Daemon: Stopping NetDB");
|
||||||
i2p::data::netdb.Stop();
|
i2p::data::netdb.Stop();
|
||||||
|
|
|
@ -461,7 +461,7 @@ namespace http {
|
||||||
if (level == "none" || level == "error" || level == "warn" || level == "info" || level == "debug")
|
if (level == "none" || level == "error" || level == "warn" || level == "info" || level == "debug")
|
||||||
i2p::log::Logger().SetLogLevel(level);
|
i2p::log::Logger().SetLogLevel(level);
|
||||||
else {
|
else {
|
||||||
LogPrint(eLogError, "HTTPServer: unknown loglevel set attempted");
|
LogPrint(eLogError, "HTTPServer: Unknown loglevel set attempted");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i2p::log::Logger().Reopen ();
|
i2p::log::Logger().Reopen ();
|
||||||
|
@ -1765,7 +1765,7 @@ namespace http {
|
||||||
if (expected == provided) return true;
|
if (expected == provided) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint(eLogWarning, "HTTPServer: auth failure from ", m_Socket->remote_endpoint().address ());
|
LogPrint(eLogWarning, "HTTPServer: Auth failure from ", m_Socket->remote_endpoint().address ());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1775,7 +1775,7 @@ namespace http {
|
||||||
std::string content;
|
std::string content;
|
||||||
HTTPRes res;
|
HTTPRes res;
|
||||||
|
|
||||||
LogPrint(eLogDebug, "HTTPServer: request: ", req.uri);
|
LogPrint(eLogDebug, "HTTPServer: Request: ", req.uri);
|
||||||
|
|
||||||
if (needAuth && !CheckAuth(req)) {
|
if (needAuth && !CheckAuth(req)) {
|
||||||
res.code = 401;
|
res.code = 401;
|
||||||
|
@ -2146,7 +2146,7 @@ namespace http {
|
||||||
pass[i] = alnum[random[i] % (sizeof(alnum) - 1)];
|
pass[i] = alnum[random[i] % (sizeof(alnum) - 1)];
|
||||||
}
|
}
|
||||||
i2p::config::SetOption("http.pass", pass);
|
i2p::config::SetOption("http.pass", pass);
|
||||||
LogPrint(eLogInfo, "HTTPServer: password set to ", pass);
|
LogPrint(eLogInfo, "HTTPServer: Password set to ", pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
|
@ -2199,7 +2199,7 @@ namespace http {
|
||||||
if (ecode)
|
if (ecode)
|
||||||
{
|
{
|
||||||
if(newSocket) newSocket->close();
|
if(newSocket) newSocket->close();
|
||||||
LogPrint(eLogError, "HTTP Server: error handling accept ", ecode.message());
|
LogPrint(eLogError, "HTTP Server: Error handling accept ", ecode.message());
|
||||||
if(ecode != boost::asio::error::operation_aborted)
|
if(ecode != boost::asio::error::operation_aborted)
|
||||||
Accept();
|
Accept();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace data
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogError, "Blinding: signature type ", (int)sigType, " is not ECDSA");
|
LogPrint (eLogError, "Blinding: Signature type ", (int)sigType, " is not ECDSA");
|
||||||
}
|
}
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ namespace data
|
||||||
size_t l = i2p::data::Base32ToByteStream (b33.c_str (), b33.length (), addr, 40);
|
size_t l = i2p::data::Base32ToByteStream (b33.c_str (), b33.length (), addr, 40);
|
||||||
if (l < 32)
|
if (l < 32)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Blinding: malformed b33 ", b33);
|
LogPrint (eLogError, "Blinding: Malformed b33 ", b33);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t checksum = crc32 (0, addr + 3, l - 3);
|
uint32_t checksum = crc32 (0, addr + 3, l - 3);
|
||||||
|
@ -186,10 +186,10 @@ namespace data
|
||||||
memcpy (m_PublicKey.data (), addr + offset, len);
|
memcpy (m_PublicKey.data (), addr + offset, len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Blinding: public key in b33 address is too short for signature type ", (int)m_SigType);
|
LogPrint (eLogError, "Blinding: Public key in b33 address is too short for signature type ", (int)m_SigType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Blinding: unknown signature type ", (int)m_SigType, " in b33");
|
LogPrint (eLogError, "Blinding: Unknown signature type ", (int)m_SigType, " in b33");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BlindedPublicKey::ToB33 () const
|
std::string BlindedPublicKey::ToB33 () const
|
||||||
|
@ -256,7 +256,7 @@ namespace data
|
||||||
publicKeyLength = i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH;
|
publicKeyLength = i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogError, "Blinding: can't blind signature type ", (int)m_SigType);
|
LogPrint (eLogError, "Blinding: Can't blind signature type ", (int)m_SigType);
|
||||||
}
|
}
|
||||||
return publicKeyLength;
|
return publicKeyLength;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ namespace data
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogError, "Blinding: can't blind signature type ", (int)m_SigType);
|
LogPrint (eLogError, "Blinding: Can't blind signature type ", (int)m_SigType);
|
||||||
}
|
}
|
||||||
return publicKeyLength;
|
return publicKeyLength;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ namespace data
|
||||||
SHA256_Final ((uint8_t *)hash, &ctx);
|
SHA256_Final ((uint8_t *)hash, &ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Blinding: blinded key type ", (int)m_BlindedSigType, " is not supported");
|
LogPrint (eLogError, "Blinding: Blinded key type ", (int)m_BlindedSigType, " is not supported");
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace client
|
||||||
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
|
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
numTags = std::stoi(it->second);
|
numTags = std::stoi(it->second);
|
||||||
LogPrint (eLogInfo, "Destination: parameters for tunnel set to: ", inQty, " inbound (", inLen, " hops), ", outQty, " outbound (", outLen, " hops), ", numTags, " tags");
|
LogPrint (eLogInfo, "Destination: Parameters for tunnel set to: ", inQty, " inbound (", inLen, " hops), ", outQty, " outbound (", outLen, " hops), ", numTags, " tags");
|
||||||
it = params->find (I2CP_PARAM_RATCHET_INBOUND_TAGS);
|
it = params->find (I2CP_PARAM_RATCHET_INBOUND_TAGS);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
SetNumRatchetInboundTags (std::stoi(it->second));
|
SetNumRatchetInboundTags (std::stoi(it->second));
|
||||||
|
@ -112,7 +112,7 @@ namespace client
|
||||||
m_LeaseSetPrivKey.reset (new i2p::data::Tag<32>());
|
m_LeaseSetPrivKey.reset (new i2p::data::Tag<32>());
|
||||||
if (m_LeaseSetPrivKey->FromBase64 (it->second) != 32)
|
if (m_LeaseSetPrivKey->FromBase64 (it->second) != 32)
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Destination: invalid value i2cp.leaseSetPrivKey ", it->second);
|
LogPrint(eLogError, "Destination: Invalid value i2cp.leaseSetPrivKey ", it->second);
|
||||||
m_LeaseSetPrivKey.reset (nullptr);
|
m_LeaseSetPrivKey.reset (nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ namespace client
|
||||||
}
|
}
|
||||||
catch (std::exception & ex)
|
catch (std::exception & ex)
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Destination: unable to parse parameters for destination: ", ex.what());
|
LogPrint(eLogError, "Destination: Unable to parse parameters for destination: ", ex.what());
|
||||||
}
|
}
|
||||||
SetNumTags (numTags);
|
SetNumTags (numTags);
|
||||||
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inLen, outLen, inQty, outQty);
|
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inLen, outLen, inQty, outQty);
|
||||||
|
@ -136,7 +136,7 @@ namespace client
|
||||||
auto minlatency = std::stoi(itr->second);
|
auto minlatency = std::stoi(itr->second);
|
||||||
if ( minlatency > 0 && maxlatency > 0 ) {
|
if ( minlatency > 0 && maxlatency > 0 ) {
|
||||||
// set tunnel pool latency
|
// set tunnel pool latency
|
||||||
LogPrint(eLogInfo, "Destination: requiring tunnel latency [", minlatency, "ms, ", maxlatency, "ms]");
|
LogPrint(eLogInfo, "Destination: Requiring tunnel latency [", minlatency, "ms, ", maxlatency, "ms]");
|
||||||
m_Pool->RequireLatency(minlatency, maxlatency);
|
m_Pool->RequireLatency(minlatency, maxlatency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ namespace client
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Destination: remote LeaseSet expired");
|
LogPrint (eLogWarning, "Destination: Remote LeaseSet expired");
|
||||||
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex);
|
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex);
|
||||||
m_RemoteLeaseSets.erase (ident);
|
m_RemoteLeaseSets.erase (ident);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -966,7 +966,7 @@ namespace client
|
||||||
}
|
}
|
||||||
catch (std::exception & ex)
|
catch (std::exception & ex)
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Destination: unable to parse parameters for destination: ", ex.what());
|
LogPrint(eLogError, "Destination: Unable to parse parameters for destination: ", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1050,7 +1050,7 @@ namespace client
|
||||||
{
|
{
|
||||||
if (!streamRequestComplete)
|
if (!streamRequestComplete)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Destination: request callback is not specified in CreateStream");
|
LogPrint (eLogError, "Destination: Request callback is not specified in CreateStream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto leaseSet = FindLeaseSet (dest);
|
auto leaseSet = FindLeaseSet (dest);
|
||||||
|
@ -1074,7 +1074,7 @@ namespace client
|
||||||
{
|
{
|
||||||
if (!streamRequestComplete)
|
if (!streamRequestComplete)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Destination: request callback is not specified in CreateStream");
|
LogPrint (eLogError, "Destination: Request callback is not specified in CreateStream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto s = GetSharedFromThis ();
|
auto s = GetSharedFromThis ();
|
||||||
|
@ -1253,7 +1253,7 @@ namespace client
|
||||||
if (m_StandardEncryptionKey && m_StandardEncryptionKey->decryptor)
|
if (m_StandardEncryptionKey && m_StandardEncryptionKey->decryptor)
|
||||||
return m_StandardEncryptionKey->decryptor->Decrypt (encrypted, data, ctx, true);
|
return m_StandardEncryptionKey->decryptor->Decrypt (encrypted, data, ctx, true);
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Destinations: decryptor is not set");
|
LogPrint (eLogError, "Destinations: Decryptor is not set");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ namespace garlic
|
||||||
newTagset->NextSessionTagRatchet ();
|
newTagset->NextSessionTagRatchet ();
|
||||||
m_SendTagset = newTagset;
|
m_SendTagset = newTagset;
|
||||||
m_SendForwardKey = false;
|
m_SendForwardKey = false;
|
||||||
LogPrint (eLogDebug, "Garlic: next send tagset ", newTagset->GetTagSetID (), " created");
|
LogPrint (eLogDebug, "Garlic: Next send tagset ", newTagset->GetTagSetID (), " created");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogDebug, "Garlic: Unexpected next key ", keyID);
|
LogPrint (eLogDebug, "Garlic: Unexpected next key ", keyID);
|
||||||
|
@ -424,7 +424,7 @@ namespace garlic
|
||||||
GenerateMoreReceiveTags (newTagset, (GetOwner () && GetOwner ()->GetNumRatchetInboundTags () > 0) ?
|
GenerateMoreReceiveTags (newTagset, (GetOwner () && GetOwner ()->GetNumRatchetInboundTags () > 0) ?
|
||||||
GetOwner ()->GetNumRatchetInboundTags () : ECIESX25519_MAX_NUM_GENERATED_TAGS);
|
GetOwner ()->GetNumRatchetInboundTags () : ECIESX25519_MAX_NUM_GENERATED_TAGS);
|
||||||
receiveTagset->Expire ();
|
receiveTagset->Expire ();
|
||||||
LogPrint (eLogDebug, "Garlic: next receive tagset ", tagsetID, " created");
|
LogPrint (eLogDebug, "Garlic: Next receive tagset ", tagsetID, " created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ namespace garlic
|
||||||
m_NextSendRatchet->key = i2p::transport::transports.GetNextX25519KeysPair ();
|
m_NextSendRatchet->key = i2p::transport::transports.GetNextX25519KeysPair ();
|
||||||
|
|
||||||
m_SendForwardKey = true;
|
m_SendForwardKey = true;
|
||||||
LogPrint (eLogDebug, "Garlic: new send ratchet ", m_NextSendRatchet->newKey ? "new" : "old", " key ", m_NextSendRatchet->keyID, " created");
|
LogPrint (eLogDebug, "Garlic: New send ratchet ", m_NextSendRatchet->newKey ? "new" : "old", " key ", m_NextSendRatchet->keyID, " created");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionMessage (const uint8_t * payload, size_t len, uint8_t * out, size_t outLen, bool isStatic)
|
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionMessage (const uint8_t * payload, size_t len, uint8_t * out, size_t outLen, bool isStatic)
|
||||||
|
@ -618,7 +618,7 @@ namespace garlic
|
||||||
bool ECIESX25519AEADRatchetSession::HandleNewOutgoingSessionReply (uint8_t * buf, size_t len)
|
bool ECIESX25519AEADRatchetSession::HandleNewOutgoingSessionReply (uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
// we are Alice
|
// we are Alice
|
||||||
LogPrint (eLogDebug, "Garlic: reply received");
|
LogPrint (eLogDebug, "Garlic: Reply received");
|
||||||
const uint8_t * tag = buf;
|
const uint8_t * tag = buf;
|
||||||
buf += 8; len -= 8; // tag
|
buf += 8; len -= 8; // tag
|
||||||
uint8_t bepk[32]; // Bob's ephemeral key
|
uint8_t bepk[32]; // Bob's ephemeral key
|
||||||
|
@ -700,7 +700,7 @@ namespace garlic
|
||||||
uint64_t tag = m_SendTagset->GetNextSessionTag ();
|
uint64_t tag = m_SendTagset->GetNextSessionTag ();
|
||||||
if (!tag)
|
if (!tag)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: can't create new ECIES-X25519-AEAD-Ratchet tag for send tagset");
|
LogPrint (eLogError, "Garlic: Can't create new ECIES-X25519-AEAD-Ratchet tag for send tagset");
|
||||||
if (GetOwner ())
|
if (GetOwner ())
|
||||||
GetOwner ()->RemoveECIESx25519Session (m_RemoteStaticKey);
|
GetOwner ()->RemoveECIESx25519Session (m_RemoteStaticKey);
|
||||||
return false;
|
return false;
|
||||||
|
@ -912,7 +912,7 @@ namespace garlic
|
||||||
{
|
{
|
||||||
if (payloadLen > I2NP_MAX_MESSAGE_SIZE)
|
if (payloadLen > I2NP_MAX_MESSAGE_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: payload length ", payloadLen, " is too long");
|
LogPrint (eLogError, "Garlic: Payload length ", payloadLen, " is too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
m_LastSentTimestamp = ts;
|
m_LastSentTimestamp = ts;
|
||||||
|
|
|
@ -590,7 +590,7 @@ namespace garlic
|
||||||
if (it->second.tagset->HandleNextMessage (buf, len, it->second.index))
|
if (it->second.tagset->HandleNextMessage (buf, len, it->second.index))
|
||||||
m_LastTagset = it->second.tagset;
|
m_LastTagset = it->second.tagset;
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Garlic: can't handle ECIES-X25519-AEAD-Ratchet message");
|
LogPrint (eLogError, "Garlic: Can't handle ECIES-X25519-AEAD-Ratchet message");
|
||||||
m_ECIESx25519Tags.erase (it);
|
m_ECIESx25519Tags.erase (it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -633,7 +633,7 @@ namespace garlic
|
||||||
SHA256 (buf, payloadSize, digest);
|
SHA256 (buf, payloadSize, digest);
|
||||||
if (memcmp (payloadHash, digest, 32)) // payload hash doesn't match
|
if (memcmp (payloadHash, digest, 32)) // payload hash doesn't match
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: wrong payload hash");
|
LogPrint (eLogError, "Garlic: Wrong payload hash");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HandleGarlicPayload (buf, payloadSize, from);
|
HandleGarlicPayload (buf, payloadSize, from);
|
||||||
|
@ -643,7 +643,7 @@ namespace garlic
|
||||||
{
|
{
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: payload is too short");
|
LogPrint (eLogError, "Garlic: Payload is too short");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int numCloves = buf[0];
|
int numCloves = buf[0];
|
||||||
|
@ -658,7 +658,7 @@ namespace garlic
|
||||||
if (flag & 0x80) // encrypted?
|
if (flag & 0x80) // encrypted?
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
LogPrint (eLogWarning, "Garlic: clove encrypted");
|
LogPrint (eLogWarning, "Garlic: Clove encrypted");
|
||||||
buf += 32;
|
buf += 32;
|
||||||
}
|
}
|
||||||
ptrdiff_t offset = buf - buf1;
|
ptrdiff_t offset = buf - buf1;
|
||||||
|
@ -666,35 +666,35 @@ namespace garlic
|
||||||
switch (deliveryType)
|
switch (deliveryType)
|
||||||
{
|
{
|
||||||
case eGarlicDeliveryTypeLocal:
|
case eGarlicDeliveryTypeLocal:
|
||||||
LogPrint (eLogDebug, "Garlic: type local");
|
LogPrint (eLogDebug, "Garlic: Type local");
|
||||||
if (offset > (int)len)
|
if (offset > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
HandleI2NPMessage (buf, len - offset);
|
HandleI2NPMessage (buf, len - offset);
|
||||||
break;
|
break;
|
||||||
case eGarlicDeliveryTypeDestination:
|
case eGarlicDeliveryTypeDestination:
|
||||||
LogPrint (eLogDebug, "Garlic: type destination");
|
LogPrint (eLogDebug, "Garlic: Type destination");
|
||||||
buf += 32; // destination. check it later or for multiple destinations
|
buf += 32; // destination. check it later or for multiple destinations
|
||||||
offset = buf - buf1;
|
offset = buf - buf1;
|
||||||
if (offset > (int)len)
|
if (offset > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
HandleI2NPMessage (buf, len - offset);
|
HandleI2NPMessage (buf, len - offset);
|
||||||
break;
|
break;
|
||||||
case eGarlicDeliveryTypeTunnel:
|
case eGarlicDeliveryTypeTunnel:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Garlic: type tunnel");
|
LogPrint (eLogDebug, "Garlic: Type tunnel");
|
||||||
// gwHash and gwTunnel sequence is reverted
|
// gwHash and gwTunnel sequence is reverted
|
||||||
uint8_t * gwHash = buf;
|
uint8_t * gwHash = buf;
|
||||||
buf += 32;
|
buf += 32;
|
||||||
offset = buf - buf1;
|
offset = buf - buf1;
|
||||||
if (offset + 4 > (int)len)
|
if (offset + 4 > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint32_t gwTunnel = bufbe32toh (buf);
|
uint32_t gwTunnel = bufbe32toh (buf);
|
||||||
|
@ -725,22 +725,22 @@ namespace garlic
|
||||||
{
|
{
|
||||||
if (offset > (int)len)
|
if (offset > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i2p::transport::transports.SendMessage (ident,
|
i2p::transport::transports.SendMessage (ident,
|
||||||
CreateI2NPMessage (buf, GetI2NPMessageLength (buf, len - offset)));
|
CreateI2NPMessage (buf, GetI2NPMessageLength (buf, len - offset)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Garlic: type router for inbound tunnels not supported");
|
LogPrint (eLogWarning, "Garlic: Type router for inbound tunnels not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogWarning, "Garlic: unknown delivery type ", (int)deliveryType);
|
LogPrint (eLogWarning, "Garlic: Unknown delivery type ", (int)deliveryType);
|
||||||
}
|
}
|
||||||
if (offset > (int)len)
|
if (offset > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buf += GetI2NPMessageLength (buf, len - offset); // I2NP
|
buf += GetI2NPMessageLength (buf, len - offset); // I2NP
|
||||||
|
@ -750,7 +750,7 @@ namespace garlic
|
||||||
offset = buf - buf1;
|
offset = buf - buf1;
|
||||||
if (offset > (int)len)
|
if (offset > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: clove is too long");
|
LogPrint (eLogError, "Garlic: Clove is too long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len -= offset;
|
len -= offset;
|
||||||
|
@ -784,7 +784,7 @@ namespace garlic
|
||||||
session = it->second;
|
session = it->second;
|
||||||
if (session->IsInactive (i2p::util::GetSecondsSinceEpoch ()))
|
if (session->IsInactive (i2p::util::GetSecondsSinceEpoch ()))
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Garlic: session restarted");
|
LogPrint (eLogDebug, "Garlic: Session restarted");
|
||||||
session = nullptr;
|
session = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1034,7 @@ namespace garlic
|
||||||
switch (deliveryType)
|
switch (deliveryType)
|
||||||
{
|
{
|
||||||
case eGarlicDeliveryTypeDestination:
|
case eGarlicDeliveryTypeDestination:
|
||||||
LogPrint (eLogDebug, "Garlic: type destination");
|
LogPrint (eLogDebug, "Garlic: Type destination");
|
||||||
buf += 32; // TODO: check destination
|
buf += 32; // TODO: check destination
|
||||||
#if (__cplusplus >= 201703L) // C++ 17 or higher
|
#if (__cplusplus >= 201703L) // C++ 17 or higher
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
@ -1042,7 +1042,7 @@ namespace garlic
|
||||||
// no break here
|
// no break here
|
||||||
case eGarlicDeliveryTypeLocal:
|
case eGarlicDeliveryTypeLocal:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Garlic: type local");
|
LogPrint (eLogDebug, "Garlic: Type local");
|
||||||
I2NPMessageType typeID = (I2NPMessageType)(buf[0]); buf++; // typeid
|
I2NPMessageType typeID = (I2NPMessageType)(buf[0]); buf++; // typeid
|
||||||
int32_t msgID = bufbe32toh (buf); buf += 4; // msgID
|
int32_t msgID = bufbe32toh (buf); buf += 4; // msgID
|
||||||
buf += 4; // expiration
|
buf += 4; // expiration
|
||||||
|
@ -1050,19 +1050,19 @@ namespace garlic
|
||||||
if (offset <= (int)len)
|
if (offset <= (int)len)
|
||||||
HandleCloveI2NPMessage (typeID, buf, len - offset, msgID);
|
HandleCloveI2NPMessage (typeID, buf, len - offset, msgID);
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Garlic: clove is too long");
|
LogPrint (eLogError, "Garlic: Clove is too long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eGarlicDeliveryTypeTunnel:
|
case eGarlicDeliveryTypeTunnel:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Garlic: type tunnel");
|
LogPrint (eLogDebug, "Garlic: Type tunnel");
|
||||||
// gwHash and gwTunnel sequence is reverted
|
// gwHash and gwTunnel sequence is reverted
|
||||||
const uint8_t * gwHash = buf;
|
const uint8_t * gwHash = buf;
|
||||||
buf += 32;
|
buf += 32;
|
||||||
ptrdiff_t offset = buf - buf1;
|
ptrdiff_t offset = buf - buf1;
|
||||||
if (offset + 13 > (int)len)
|
if (offset + 13 > (int)len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: message is too short");
|
LogPrint (eLogError, "Garlic: Message is too short");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint32_t gwTunnel = bufbe32toh (buf); buf += 4;
|
uint32_t gwTunnel = bufbe32toh (buf); buf += 4;
|
||||||
|
@ -1083,7 +1083,7 @@ namespace garlic
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogWarning, "Garlic: unexpected delivery type ", (int)deliveryType);
|
LogPrint (eLogWarning, "Garlic: Unexpected delivery type ", (int)deliveryType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
auto msg = NewI2NPMessage (len);
|
auto msg = NewI2NPMessage (len);
|
||||||
if (msg->Concat (buf, len) < len)
|
if (msg->Concat (buf, len) < len)
|
||||||
LogPrint (eLogError, "I2NP: message length ", len, " exceeds max length ", msg->maxLen);
|
LogPrint (eLogError, "I2NP: Message length ", len, " exceeds max length ", msg->maxLen);
|
||||||
msg->FillI2NPMessageHeader (msgType, replyMsgID);
|
msg->FillI2NPMessageHeader (msgType, replyMsgID);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ namespace i2p
|
||||||
msg->from = from;
|
msg->from = from;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "I2NP: message length ", len, " exceeds max length");
|
LogPrint (eLogError, "I2NP: Message length ", len, " exceeds max length");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,7 +778,7 @@ namespace i2p
|
||||||
htobe16buf (payload + TUNNEL_GATEWAY_HEADER_LENGTH_OFFSET, len);
|
htobe16buf (payload + TUNNEL_GATEWAY_HEADER_LENGTH_OFFSET, len);
|
||||||
msg->len += TUNNEL_GATEWAY_HEADER_SIZE;
|
msg->len += TUNNEL_GATEWAY_HEADER_SIZE;
|
||||||
if (msg->Concat (buf, len) < len)
|
if (msg->Concat (buf, len) < len)
|
||||||
LogPrint (eLogError, "I2NP: tunnel gateway buffer overflow ", msg->maxLen);
|
LogPrint (eLogError, "I2NP: Tunnel gateway buffer overflow ", msg->maxLen);
|
||||||
msg->FillI2NPMessageHeader (eI2NPTunnelGateway);
|
msg->FillI2NPMessageHeader (eI2NPTunnelGateway);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ namespace i2p
|
||||||
msg->offset += gatewayMsgOffset;
|
msg->offset += gatewayMsgOffset;
|
||||||
msg->len += gatewayMsgOffset;
|
msg->len += gatewayMsgOffset;
|
||||||
if (msg->Concat (buf, len) < len)
|
if (msg->Concat (buf, len) < len)
|
||||||
LogPrint (eLogError, "I2NP: tunnel gateway buffer overflow ", msg->maxLen);
|
LogPrint (eLogError, "I2NP: Tunnel gateway buffer overflow ", msg->maxLen);
|
||||||
msg->FillI2NPMessageHeader (msgType, replyMsgID); // create content message
|
msg->FillI2NPMessageHeader (msgType, replyMsgID); // create content message
|
||||||
len = msg->GetLength ();
|
len = msg->GetLength ();
|
||||||
msg->offset -= gatewayMsgOffset;
|
msg->offset -= gatewayMsgOffset;
|
||||||
|
@ -824,13 +824,13 @@ namespace i2p
|
||||||
{
|
{
|
||||||
if (len < I2NP_HEADER_SIZE_OFFSET + 2)
|
if (len < I2NP_HEADER_SIZE_OFFSET + 2)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2NP: message length ", len, " is smaller than header");
|
LogPrint (eLogError, "I2NP: Message length ", len, " is smaller than header");
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
auto l = bufbe16toh (msg + I2NP_HEADER_SIZE_OFFSET) + I2NP_HEADER_SIZE;
|
auto l = bufbe16toh (msg + I2NP_HEADER_SIZE_OFFSET) + I2NP_HEADER_SIZE;
|
||||||
if (l > len)
|
if (l > len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2NP: message length ", l, " exceeds buffer length ", len);
|
LogPrint (eLogError, "I2NP: Message length ", l, " exceeds buffer length ", len);
|
||||||
l = len;
|
l = len;
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
|
@ -840,18 +840,18 @@ namespace i2p
|
||||||
{
|
{
|
||||||
if (len < I2NP_HEADER_SIZE)
|
if (len < I2NP_HEADER_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2NP: message length ", len, " is smaller than header");
|
LogPrint (eLogError, "I2NP: Message length ", len, " is smaller than header");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t typeID = msg[I2NP_HEADER_TYPEID_OFFSET];
|
uint8_t typeID = msg[I2NP_HEADER_TYPEID_OFFSET];
|
||||||
uint32_t msgID = bufbe32toh (msg + I2NP_HEADER_MSGID_OFFSET);
|
uint32_t msgID = bufbe32toh (msg + I2NP_HEADER_MSGID_OFFSET);
|
||||||
LogPrint (eLogDebug, "I2NP: msg received len=", len,", type=", (int)typeID, ", msgID=", (unsigned int)msgID);
|
LogPrint (eLogDebug, "I2NP: Message received len=", len,", type=", (int)typeID, ", msgID=", (unsigned int)msgID);
|
||||||
uint8_t * buf = msg + I2NP_HEADER_SIZE;
|
uint8_t * buf = msg + I2NP_HEADER_SIZE;
|
||||||
auto size = bufbe16toh (msg + I2NP_HEADER_SIZE_OFFSET);
|
auto size = bufbe16toh (msg + I2NP_HEADER_SIZE_OFFSET);
|
||||||
len -= I2NP_HEADER_SIZE;
|
len -= I2NP_HEADER_SIZE;
|
||||||
if (size > len)
|
if (size > len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2NP: payload size ", size, " exceeds buffer length ", len);
|
LogPrint (eLogError, "I2NP: Payload size ", size, " exceeds buffer length ", len);
|
||||||
size = len;
|
size = len;
|
||||||
}
|
}
|
||||||
switch (typeID)
|
switch (typeID)
|
||||||
|
|
|
@ -217,7 +217,7 @@ namespace data
|
||||||
{
|
{
|
||||||
if (len < DEFAULT_IDENTITY_SIZE)
|
if (len < DEFAULT_IDENTITY_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Identity: buffer length ", len, " is too small");
|
LogPrint (eLogError, "Identity: Buffer length ", len, " is too small");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy (&m_StandardIdentity, buf, DEFAULT_IDENTITY_SIZE);
|
memcpy (&m_StandardIdentity, buf, DEFAULT_IDENTITY_SIZE);
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace data
|
||||||
LogPrint (eLogDebug, "LeaseSet: read num=", (int)num);
|
LogPrint (eLogDebug, "LeaseSet: read num=", (int)num);
|
||||||
if (!num || num > MAX_NUM_LEASES)
|
if (!num || num > MAX_NUM_LEASES)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet: incorrect number of leases", (int)num);
|
LogPrint (eLogError, "LeaseSet: Incorrect number of leases", (int)num);
|
||||||
m_IsValid = false;
|
m_IsValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ namespace data
|
||||||
}
|
}
|
||||||
if (!m_ExpirationTime)
|
if (!m_ExpirationTime)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "LeaseSet: all leases are expired. Dropped");
|
LogPrint (eLogWarning, "LeaseSet: All leases have expired, dropping");
|
||||||
m_IsValid = false;
|
m_IsValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ namespace data
|
||||||
}
|
}
|
||||||
else if (!m_Identity->Verify (m_Buffer, signedSize, leases))
|
else if (!m_Identity->Verify (m_Buffer, signedSize, leases))
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "LeaseSet: verification failed");
|
LogPrint (eLogWarning, "LeaseSet: Verification failed");
|
||||||
m_IsValid = false;
|
m_IsValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ namespace data
|
||||||
{
|
{
|
||||||
if (len <= m_BufferLen) m_BufferLen = len;
|
if (len <= m_BufferLen) m_BufferLen = len;
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "LeaseSet2: actual buffer size ", len , " exceeds full buffer size ", m_BufferLen);
|
LogPrint (eLogError, "LeaseSet2: Actual buffer size ", len , " exceeds full buffer size ", m_BufferLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases, CryptoKeyType preferredCrypto):
|
LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases, CryptoKeyType preferredCrypto):
|
||||||
|
@ -331,7 +331,7 @@ namespace data
|
||||||
m_TransientVerifier = ProcessOfflineSignature (identity, buf, len, offset);
|
m_TransientVerifier = ProcessOfflineSignature (identity, buf, len, offset);
|
||||||
if (!m_TransientVerifier)
|
if (!m_TransientVerifier)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet2: offline signature failed");
|
LogPrint (eLogError, "LeaseSet2: Offline signature failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ namespace data
|
||||||
bool verified = verifier->Verify (buf - 1, signatureOffset + 1, buf + signatureOffset);
|
bool verified = verifier->Verify (buf - 1, signatureOffset + 1, buf + signatureOffset);
|
||||||
const_cast<uint8_t *>(buf)[-1] = c;
|
const_cast<uint8_t *>(buf)[-1] = c;
|
||||||
if (!verified)
|
if (!verified)
|
||||||
LogPrint (eLogWarning, "LeaseSet2: verification failed");
|
LogPrint (eLogWarning, "LeaseSet2: Verification failed");
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ namespace data
|
||||||
m_TransientVerifier = ProcessOfflineSignature (blindedVerifier, buf, len, offset);
|
m_TransientVerifier = ProcessOfflineSignature (blindedVerifier, buf, len, offset);
|
||||||
if (!m_TransientVerifier)
|
if (!m_TransientVerifier)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet2: offline signature failed");
|
LogPrint (eLogError, "LeaseSet2: Offline signature failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ namespace data
|
||||||
key->GetBlindedKey (date, blinded.data ());
|
key->GetBlindedKey (date, blinded.data ());
|
||||||
if (memcmp (blindedPublicKey, blinded.data (), blindedKeyLen))
|
if (memcmp (blindedPublicKey, blinded.data (), blindedKeyLen))
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet2: blinded public key doesn't match");
|
LogPrint (eLogError, "LeaseSet2: Blinded public key doesn't match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ namespace data
|
||||||
ReadFromBuffer (innerPlainText.data () + 1, lenInnerPlaintext - 1);
|
ReadFromBuffer (innerPlainText.data () + 1, lenInnerPlaintext - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "LeaseSet2: unexpected LeaseSet type ", (int)innerPlainText[0], " inside encrypted LeaseSet");
|
LogPrint (eLogError, "LeaseSet2: Unexpected LeaseSet type ", (int)innerPlainText[0], " inside encrypted LeaseSet");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -653,7 +653,7 @@ namespace data
|
||||||
LogPrint (eLogError, "LeaseSet2: Can't calculate authCookie: psk_i is not provided");
|
LogPrint (eLogError, "LeaseSet2: Can't calculate authCookie: psk_i is not provided");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "LeaseSet2: unknown client auth type ", (int)flag);
|
LogPrint (eLogError, "LeaseSet2: Unknown client auth type ", (int)flag);
|
||||||
}
|
}
|
||||||
return offset - 1;
|
return offset - 1;
|
||||||
}
|
}
|
||||||
|
@ -768,7 +768,7 @@ namespace data
|
||||||
size_t size = ident.GetFullLen ();
|
size_t size = ident.GetFullLen ();
|
||||||
if (size > sz)
|
if (size > sz)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet: identity length ", size, " exceeds buffer size ", sz);
|
LogPrint (eLogError, "LeaseSet: Identity length ", size, " exceeds buffer size ", sz);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// encryption key
|
// encryption key
|
||||||
|
@ -779,7 +779,7 @@ namespace data
|
||||||
++size;
|
++size;
|
||||||
if (!numLeases || numLeases > MAX_NUM_LEASES)
|
if (!numLeases || numLeases > MAX_NUM_LEASES)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "LeaseSet: incorrect number of leases", (int)numLeases);
|
LogPrint (eLogError, "LeaseSet: Incorrect number of leases", (int)numLeases);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const uint8_t * leases = ptr + size;
|
const uint8_t * leases = ptr + size;
|
||||||
|
@ -979,7 +979,7 @@ namespace data
|
||||||
m_StoreHash = blindedKey->GetStoreHash ();
|
m_StoreHash = blindedKey->GetStoreHash ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "LeaseSet2: couldn't extract inner layer");
|
LogPrint (eLogError, "LeaseSet2: Couldn't extract inner layer");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalEncryptedLeaseSet2::CreateClientAuthData (const uint8_t * subcredential, int authType, std::shared_ptr<std::vector<AuthPublicKey> > authKeys, const uint8_t * authCookie, uint8_t * authData) const
|
void LocalEncryptedLeaseSet2::CreateClientAuthData (const uint8_t * subcredential, int authType, std::shared_ptr<std::vector<AuthPublicKey> > authKeys, const uint8_t * authCookie, uint8_t * authData) const
|
||||||
|
|
|
@ -129,10 +129,10 @@ namespace log {
|
||||||
else if (level == "info") { m_MinLevel = eLogInfo; }
|
else if (level == "info") { m_MinLevel = eLogInfo; }
|
||||||
else if (level == "debug") { m_MinLevel = eLogDebug; }
|
else if (level == "debug") { m_MinLevel = eLogDebug; }
|
||||||
else {
|
else {
|
||||||
LogPrint(eLogError, "Log: unknown loglevel: ", level);
|
LogPrint(eLogError, "Log: Unknown loglevel: ", level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogPrint(eLogInfo, "Log: min messages level set to ", level);
|
LogPrint(eLogInfo, "Log: Logging level set to ", level);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * Log::TimeAsString(std::time_t t) {
|
const char * Log::TimeAsString(std::time_t t) {
|
||||||
|
@ -212,7 +212,7 @@ namespace log {
|
||||||
m_LogStream = os;
|
m_LogStream = os;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogPrint(eLogError, "Log: can't open file ", path);
|
LogPrint(eLogError, "Log: Can't open file ", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::SendTo (std::shared_ptr<std::ostream> os) {
|
void Log::SendTo (std::shared_ptr<std::ostream> os) {
|
||||||
|
|
|
@ -341,7 +341,7 @@ namespace data
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "NetDb: new LeaseSet validation failed: ", ident.ToBase32());
|
LogPrint (eLogError, "NetDb: New LeaseSet validation failed: ", ident.ToBase32());
|
||||||
}
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "NetDb: new LeaseSet2 validation failed: ", ident.ToBase32());
|
LogPrint (eLogError, "NetDb: New LeaseSet2 validation failed: ", ident.ToBase32());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ namespace data
|
||||||
int riLen = ri->GetBufferLen();
|
int riLen = ri->GetBufferLen();
|
||||||
if(!i2p::data::netdb.AddRouterInfo(riData, riLen)) {
|
if(!i2p::data::netdb.AddRouterInfo(riData, riLen)) {
|
||||||
// bad router info
|
// bad router info
|
||||||
LogPrint(eLogError, "NetDb: bad router info");
|
LogPrint(eLogError, "NetDb: Bad RouterInfo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_FloodfillBootstrap = ri;
|
m_FloodfillBootstrap = ri;
|
||||||
|
@ -443,7 +443,7 @@ namespace data
|
||||||
|
|
||||||
void NetDb::ReseedFromFloodfill(const RouterInfo & ri, int numRouters, int numFloodfills)
|
void NetDb::ReseedFromFloodfill(const RouterInfo & ri, int numRouters, int numFloodfills)
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo, "NetDB: reseeding from floodfill ", ri.GetIdentHashBase64());
|
LogPrint(eLogInfo, "NetDB: Reseeding from floodfill ", ri.GetIdentHashBase64());
|
||||||
std::vector<std::shared_ptr<i2p::I2NPMessage> > requests;
|
std::vector<std::shared_ptr<i2p::I2NPMessage> > requests;
|
||||||
|
|
||||||
i2p::data::IdentHash ourIdent = i2p::context.GetIdentHash();
|
i2p::data::IdentHash ourIdent = i2p::context.GetIdentHash();
|
||||||
|
@ -626,10 +626,10 @@ namespace data
|
||||||
} // m_RouterInfos iteration
|
} // m_RouterInfos iteration
|
||||||
|
|
||||||
if (updatedCount > 0)
|
if (updatedCount > 0)
|
||||||
LogPrint (eLogInfo, "NetDb: saved ", updatedCount, " new/updated routers");
|
LogPrint (eLogInfo, "NetDb: Saved ", updatedCount, " new/updated routers");
|
||||||
if (deletedCount > 0)
|
if (deletedCount > 0)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: deleting ", deletedCount, " unreachable routers");
|
LogPrint (eLogInfo, "NetDb: Deleting ", deletedCount, " unreachable routers");
|
||||||
// clean up RouterInfos table
|
// clean up RouterInfos table
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
|
@ -661,7 +661,7 @@ namespace data
|
||||||
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
|
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
|
||||||
if (!dest)
|
if (!dest)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "NetDb: destination ", destination.ToBase64(), " is requested already");
|
LogPrint (eLogWarning, "NetDb: Destination ", destination.ToBase64(), " has already been requested");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ namespace data
|
||||||
IdentHash ident (buf + DATABASE_STORE_KEY_OFFSET);
|
IdentHash ident (buf + DATABASE_STORE_KEY_OFFSET);
|
||||||
if (ident.IsZero ())
|
if (ident.IsZero ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: database store with zero ident, dropped");
|
LogPrint (eLogDebug, "NetDb: Database store with zero ident, dropped");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t replyToken = bufbe32toh (buf + DATABASE_STORE_REPLY_TOKEN_OFFSET);
|
uint32_t replyToken = bufbe32toh (buf + DATABASE_STORE_REPLY_TOKEN_OFFSET);
|
||||||
|
@ -746,14 +746,14 @@ namespace data
|
||||||
if (outbound)
|
if (outbound)
|
||||||
outbound->SendTunnelDataMsg (buf + offset, tunnelID, deliveryStatus);
|
outbound->SendTunnelDataMsg (buf + offset, tunnelID, deliveryStatus);
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "NetDb: no outbound tunnels for DatabaseStore reply found");
|
LogPrint (eLogWarning, "NetDb: No outbound tunnels for DatabaseStore reply found");
|
||||||
}
|
}
|
||||||
offset += 32;
|
offset += 32;
|
||||||
}
|
}
|
||||||
// we must send reply back before this check
|
// we must send reply back before this check
|
||||||
if (ident == i2p::context.GetIdentHash ())
|
if (ident == i2p::context.GetIdentHash ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: database store with own RouterInfo received, dropped");
|
LogPrint (eLogDebug, "NetDb: Database store with own RouterInfo received, dropped");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t payloadOffset = offset;
|
size_t payloadOffset = offset;
|
||||||
|
@ -766,24 +766,24 @@ namespace data
|
||||||
{
|
{
|
||||||
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
|
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: store request: LeaseSet for ", ident.ToBase32());
|
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet for ", ident.ToBase32());
|
||||||
updated = AddLeaseSet (ident, buf + offset, len - offset);
|
updated = AddLeaseSet (ident, buf + offset, len - offset);
|
||||||
}
|
}
|
||||||
else // all others are considered as LeaseSet2
|
else // all others are considered as LeaseSet2
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: store request: LeaseSet2 of type ", storeType, " for ", ident.ToBase32());
|
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", storeType, " for ", ident.ToBase32());
|
||||||
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
|
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // RouterInfo
|
else // RouterInfo
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: store request: RouterInfo");
|
LogPrint (eLogDebug, "NetDb: Store request: RouterInfo");
|
||||||
size_t size = bufbe16toh (buf + offset);
|
size_t size = bufbe16toh (buf + offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
if (size > MAX_RI_BUFFER_SIZE || size > len - offset)
|
if (size > MAX_RI_BUFFER_SIZE || size > len - offset)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "NetDb: invalid RouterInfo length ", (int)size);
|
LogPrint (eLogError, "NetDb: Invalid RouterInfo length ", (int)size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t uncompressed[MAX_RI_BUFFER_SIZE];
|
uint8_t uncompressed[MAX_RI_BUFFER_SIZE];
|
||||||
|
@ -792,7 +792,7 @@ namespace data
|
||||||
updated = AddRouterInfo (ident, uncompressed, uncompressedSize);
|
updated = AddRouterInfo (ident, uncompressed, uncompressedSize);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: decompression failed ", uncompressedSize);
|
LogPrint (eLogInfo, "NetDb: Decompression failed ", uncompressedSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ namespace data
|
||||||
m_Requests.RequestComplete (ident, nullptr);
|
m_Requests.RequestComplete (ident, nullptr);
|
||||||
}
|
}
|
||||||
else if(!m_FloodfillBootstrap)
|
else if(!m_FloodfillBootstrap)
|
||||||
LogPrint (eLogWarning, "NetDb: requested destination for ", key, " not found");
|
LogPrint (eLogWarning, "NetDb: Requested destination for ", key, " not found");
|
||||||
|
|
||||||
// try responses
|
// try responses
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
|
@ -882,7 +882,7 @@ namespace data
|
||||||
if (!r || i2p::util::GetMillisecondsSinceEpoch () > r->GetTimestamp () + 3600*1000LL)
|
if (!r || i2p::util::GetMillisecondsSinceEpoch () > r->GetTimestamp () + 3600*1000LL)
|
||||||
{
|
{
|
||||||
// router with ident not found or too old (1 hour)
|
// router with ident not found or too old (1 hour)
|
||||||
LogPrint (eLogDebug, "NetDb: found new/outdated router. Requesting RouterInfo ...");
|
LogPrint (eLogDebug, "NetDb: Found new/outdated router. Requesting RouterInfo ...");
|
||||||
if(m_FloodfillBootstrap)
|
if(m_FloodfillBootstrap)
|
||||||
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
|
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
|
||||||
else
|
else
|
||||||
|
@ -923,14 +923,14 @@ namespace data
|
||||||
excluded += 2;
|
excluded += 2;
|
||||||
if (numExcluded > 512)
|
if (numExcluded > 512)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "NetDb: number of excluded peers", numExcluded, " exceeds 512");
|
LogPrint (eLogWarning, "NetDb: Number of excluded peers", numExcluded, " exceeds 512");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> replyMsg;
|
std::shared_ptr<I2NPMessage> replyMsg;
|
||||||
if (lookupType == DATABASE_LOOKUP_TYPE_EXPLORATORY_LOOKUP)
|
if (lookupType == DATABASE_LOOKUP_TYPE_EXPLORATORY_LOOKUP)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: exploratory close to ", key, " ", numExcluded, " excluded");
|
LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded");
|
||||||
std::set<IdentHash> excludedRouters;
|
std::set<IdentHash> excludedRouters;
|
||||||
for (int i = 0; i < numExcluded; i++)
|
for (int i = 0; i < numExcluded; i++)
|
||||||
{
|
{
|
||||||
|
@ -957,7 +957,7 @@ namespace data
|
||||||
auto router = FindRouter (ident);
|
auto router = FindRouter (ident);
|
||||||
if (router)
|
if (router)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: requested RouterInfo ", key, " found");
|
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
|
||||||
router->LoadBuffer ();
|
router->LoadBuffer ();
|
||||||
if (router->GetBuffer ())
|
if (router->GetBuffer ())
|
||||||
replyMsg = CreateDatabaseStoreMsg (router);
|
replyMsg = CreateDatabaseStoreMsg (router);
|
||||||
|
@ -971,11 +971,11 @@ namespace data
|
||||||
if (!leaseSet)
|
if (!leaseSet)
|
||||||
{
|
{
|
||||||
// no lease set found
|
// no lease set found
|
||||||
LogPrint(eLogDebug, "NetDb: requested LeaseSet not found for ", ident.ToBase32());
|
LogPrint(eLogDebug, "NetDb: Requested LeaseSet not found for ", ident.ToBase32());
|
||||||
}
|
}
|
||||||
else if (!leaseSet->IsExpired ()) // we don't send back our LeaseSets
|
else if (!leaseSet->IsExpired ()) // we don't send back our LeaseSets
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: requested LeaseSet ", key, " found");
|
LogPrint (eLogDebug, "NetDb: Requested LeaseSet ", key, " found");
|
||||||
replyMsg = CreateDatabaseStoreMsg (ident, leaseSet);
|
replyMsg = CreateDatabaseStoreMsg (ident, leaseSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1057,14 +1057,14 @@ namespace data
|
||||||
|
|
||||||
uint8_t randomHash[32];
|
uint8_t randomHash[32];
|
||||||
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
LogPrint (eLogInfo, "NetDb: exploring new ", numDestinations, " routers ...");
|
LogPrint (eLogInfo, "NetDb: Exploring new ", numDestinations, " routers ...");
|
||||||
for (int i = 0; i < numDestinations; i++)
|
for (int i = 0; i < numDestinations; i++)
|
||||||
{
|
{
|
||||||
RAND_bytes (randomHash, 32);
|
RAND_bytes (randomHash, 32);
|
||||||
auto dest = m_Requests.CreateRequest (randomHash, true); // exploratory
|
auto dest = m_Requests.CreateRequest (randomHash, true); // exploratory
|
||||||
if (!dest)
|
if (!dest)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "NetDb: exploratory destination is requested already");
|
LogPrint (eLogWarning, "NetDb: Exploratory destination is requested already");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace data
|
||||||
|
|
||||||
if (!i2p::fs::Exists(path))
|
if (!i2p::fs::Exists(path))
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning, "Profiling: no profile yet for ", ident);
|
LogPrint(eLogWarning, "Profiling: No profile yet for ", ident);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ namespace data
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (((now - st.st_mtime) / 3600) >= PEER_PROFILE_EXPIRATION_TIMEOUT) {
|
if (((now - st.st_mtime) / 3600) >= PEER_PROFILE_EXPIRATION_TIMEOUT) {
|
||||||
LogPrint(eLogDebug, "Profiling: removing expired peer profile: ", path);
|
LogPrint(eLogDebug, "Profiling: Removing expired peer profile: ", path);
|
||||||
i2p::fs::Remove(path);
|
i2p::fs::Remove(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,19 +60,19 @@ namespace data
|
||||||
num = ProcessSU3File (su3FileName.c_str ());
|
num = ProcessSU3File (su3FileName.c_str ());
|
||||||
}
|
}
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
LogPrint (eLogWarning, "Reseed: failed to reseed from ", su3FileName);
|
LogPrint (eLogWarning, "Reseed: Failed to reseed from ", su3FileName);
|
||||||
}
|
}
|
||||||
else if (zipFileName.length() > 0) // bootstrap from ZIP file
|
else if (zipFileName.length() > 0) // bootstrap from ZIP file
|
||||||
{
|
{
|
||||||
int num = ProcessZIPFile (zipFileName.c_str ());
|
int num = ProcessZIPFile (zipFileName.c_str ());
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
LogPrint (eLogWarning, "Reseed: failed to reseed from ", zipFileName);
|
LogPrint (eLogWarning, "Reseed: Failed to reseed from ", zipFileName);
|
||||||
}
|
}
|
||||||
else // bootstrap from reseed servers
|
else // bootstrap from reseed servers
|
||||||
{
|
{
|
||||||
int num = ReseedFromServers ();
|
int num = ReseedFromServers ();
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
LogPrint (eLogWarning, "Reseed: failed to reseed from servers");
|
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ namespace data
|
||||||
if (num > 0) return num; // success
|
if (num > 0) return num; // success
|
||||||
reseedRetries++;
|
reseedRetries++;
|
||||||
}
|
}
|
||||||
LogPrint (eLogWarning, "Reseed: failed to reseed from servers after 10 attempts");
|
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers after 10 attempts");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ namespace data
|
||||||
|
|
||||||
for (const std::string & file : files) {
|
for (const std::string & file : files) {
|
||||||
if (file.compare(file.size() - 4, 4, ".crt") != 0) {
|
if (file.compare(file.size() - 4, 4, ".crt") != 0) {
|
||||||
LogPrint(eLogWarning, "Reseed: ignoring file ", file);
|
LogPrint(eLogWarning, "Reseed: Ignoring file ", file);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LoadCertificate (file);
|
LoadCertificate (file);
|
||||||
|
@ -533,17 +533,17 @@ namespace data
|
||||||
}
|
}
|
||||||
// check for valid proxy url schema
|
// check for valid proxy url schema
|
||||||
if (proxyUrl.schema != "http" && proxyUrl.schema != "socks") {
|
if (proxyUrl.schema != "http" && proxyUrl.schema != "socks") {
|
||||||
LogPrint(eLogError, "Reseed: bad proxy url: ", proxy);
|
LogPrint(eLogError, "Reseed: Bad proxy URL: ", proxy);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogPrint(eLogError, "Reseed: bad proxy url: ", proxy);
|
LogPrint(eLogError, "Reseed: Bad proxy URL: ", proxy);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i2p::http::URL url;
|
i2p::http::URL url;
|
||||||
if (!url.parse(address)) {
|
if (!url.parse(address)) {
|
||||||
LogPrint(eLogError, "Reseed: failed to parse url: ", address);
|
LogPrint(eLogError, "Reseed: Failed to parse URL: ", address);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
url.schema = "https";
|
url.schema = "https";
|
||||||
|
@ -743,22 +743,22 @@ namespace data
|
||||||
i2p::http::HTTPRes res;
|
i2p::http::HTTPRes res;
|
||||||
int len = res.parse(data);
|
int len = res.parse(data);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
LogPrint(eLogWarning, "Reseed: incomplete/broken response from ", uri);
|
LogPrint(eLogWarning, "Reseed: Incomplete/broken response from ", uri);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
LogPrint(eLogError, "Reseed: failed to reseed from ", uri, ", http code ", res.code);
|
LogPrint(eLogError, "Reseed: Failed to reseed from ", uri, ", http code ", res.code);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
data.erase(0, len); /* drop http headers from response */
|
data.erase(0, len); /* drop http headers from response */
|
||||||
LogPrint(eLogDebug, "Reseed: got ", data.length(), " bytes of data from ", uri);
|
LogPrint(eLogDebug, "Reseed: Got ", data.length(), " bytes of data from ", uri);
|
||||||
if (res.is_chunked()) {
|
if (res.is_chunked()) {
|
||||||
std::stringstream in(data), out;
|
std::stringstream in(data), out;
|
||||||
if (!i2p::http::MergeChunkedResponse(in, out)) {
|
if (!i2p::http::MergeChunkedResponse(in, out)) {
|
||||||
LogPrint(eLogWarning, "Reseed: failed to merge chunked response from ", uri);
|
LogPrint(eLogWarning, "Reseed: Failed to merge chunked response from ", uri);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
LogPrint(eLogDebug, "Reseed: got ", data.length(), "(", out.tellg(), ") bytes of data from ", uri);
|
LogPrint(eLogDebug, "Reseed: Got ", data.length(), "(", out.tellg(), ") bytes of data from ", uri);
|
||||||
data = out.str();
|
data = out.str();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -769,7 +769,7 @@ namespace data
|
||||||
i2p::http::URL url;
|
i2p::http::URL url;
|
||||||
if (!url.parse(address))
|
if (!url.parse(address))
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Reseed: failed to parse url: ", address);
|
LogPrint(eLogError, "Reseed: Failed to parse URL: ", address);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
url.schema = "http";
|
url.schema = "http";
|
||||||
|
|
|
@ -809,7 +809,7 @@ namespace data
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "RouterInfo: string length ", (int)l, " exceeds buffer size ", len);
|
LogPrint (eLogWarning, "RouterInfo: String length ", (int)l, " exceeds buffer size ", len);
|
||||||
s.seekg (l, std::ios::cur); // skip
|
s.seekg (l, std::ios::cur); // skip
|
||||||
str[0] = 0;
|
str[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch ( std::exception & ex )
|
catch ( std::exception & ex )
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: failed to bind to v4 port ", m_Endpoint.port(), ": ", ex.what());
|
LogPrint (eLogError, "SSU: Failed to bind to v4 port ", m_Endpoint.port(), ": ", ex.what());
|
||||||
ThrowFatal ("Unable to start IPv4 SSU transport at port ", m_Endpoint.port(), ": ", ex.what ());
|
ThrowFatal ("Unable to start IPv4 SSU transport at port ", m_Endpoint.port(), ": ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch ( std::exception & ex )
|
catch ( std::exception & ex )
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: failed to bind to v6 port ", m_EndpointV6.port(), ": ", ex.what());
|
LogPrint (eLogError, "SSU: Failed to bind to v6 port ", m_EndpointV6.port(), ": ", ex.what());
|
||||||
ThrowFatal ("Unable to start IPv6 SSU transport at port ", m_Endpoint.port(), ": ", ex.what ());
|
ThrowFatal ("Unable to start IPv6 SSU transport at port ", m_Endpoint.port(), ": ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: server runtime exception: ", ex.what ());
|
LogPrint (eLogError, "SSU: Server runtime exception: ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: receivers runtime exception: ", ex.what ());
|
LogPrint (eLogError, "SSU: Receivers runtime exception: ", ex.what ());
|
||||||
if (m_IsRunning)
|
if (m_IsRunning)
|
||||||
{
|
{
|
||||||
// restart socket
|
// restart socket
|
||||||
|
@ -249,7 +249,7 @@ namespace transport
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: send exception: ", ec.message (), " while trying to send data to ", to.address (), ":", to.port (), " (length: ", len, ")");
|
LogPrint (eLogError, "SSU: Send exception: ", ec.message (), " while trying to send data to ", to.address (), ":", to.port (), " (length: ", len, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ namespace transport
|
||||||
delete packet;
|
delete packet;
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: receive error: code ", ecode.value(), ": ", ecode.message ());
|
LogPrint (eLogError, "SSU: Receive error: code ", ecode.value(), ": ", ecode.message ());
|
||||||
m_Socket.close ();
|
m_Socket.close ();
|
||||||
OpenSocket ();
|
OpenSocket ();
|
||||||
Receive ();
|
Receive ();
|
||||||
|
@ -409,7 +409,7 @@ namespace transport
|
||||||
session = std::make_shared<SSUSession> (*this, packet->from);
|
session = std::make_shared<SSUSession> (*this, packet->from);
|
||||||
session->WaitForConnect ();
|
session->WaitForConnect ();
|
||||||
(*sessions)[packet->from] = session;
|
(*sessions)[packet->from] = session;
|
||||||
LogPrint (eLogDebug, "SSU: new session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
LogPrint (eLogDebug, "SSU: New session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session)
|
if (session)
|
||||||
|
@ -797,7 +797,7 @@ namespace transport
|
||||||
if (sessions.empty () && !introducers.empty ())
|
if (sessions.empty () && !introducers.empty ())
|
||||||
{
|
{
|
||||||
// bump creation time for previous introducers if no new sessions found
|
// bump creation time for previous introducers if no new sessions found
|
||||||
LogPrint (eLogDebug, "SSU: no new introducers found. Trying to reuse existing");
|
LogPrint (eLogDebug, "SSU: No new introducers found. Trying to reuse existing");
|
||||||
for (const auto& it : introducers)
|
for (const auto& it : introducers)
|
||||||
{
|
{
|
||||||
auto session = FindSession (it);
|
auto session = FindSession (it);
|
||||||
|
@ -847,7 +847,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: can't find more introducers");
|
LogPrint (eLogDebug, "SSU: Can't find more introducers");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -940,10 +940,10 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto session = it.second;
|
auto session = it.second;
|
||||||
if (it.first != session->GetRemoteEndpoint ())
|
if (it.first != session->GetRemoteEndpoint ())
|
||||||
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted");
|
LogPrint (eLogWarning, "SSU: Remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted");
|
||||||
m_Service.post ([session]
|
m_Service.post ([session]
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
LogPrint (eLogWarning, "SSU: No activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
||||||
session->Failed ();
|
session->Failed ();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -968,10 +968,10 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto session = it.second;
|
auto session = it.second;
|
||||||
if (it.first != session->GetRemoteEndpoint ())
|
if (it.first != session->GetRemoteEndpoint ())
|
||||||
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first);
|
LogPrint (eLogWarning, "SSU: Remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first);
|
||||||
m_Service.post ([session]
|
m_Service.post ([session]
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
LogPrint (eLogWarning, "SSU: No activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
||||||
session->Failed ();
|
session->Failed ();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,12 +177,12 @@ namespace transport
|
||||||
ProcessSessionConfirmed (buf, len); // buf with header
|
ProcessSessionConfirmed (buf, len); // buf with header
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_PEER_TEST:
|
case PAYLOAD_TYPE_PEER_TEST:
|
||||||
LogPrint (eLogDebug, "SSU: peer test received");
|
LogPrint (eLogDebug, "SSU: Peer test received");
|
||||||
ProcessPeerTest (buf + headerSize, len - headerSize, senderEndpoint);
|
ProcessPeerTest (buf + headerSize, len - headerSize, senderEndpoint);
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_SESSION_DESTROYED:
|
case PAYLOAD_TYPE_SESSION_DESTROYED:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: session destroy received");
|
LogPrint (eLogDebug, "SSU: Session destroy received");
|
||||||
m_Server.DeleteSession (shared_from_this ());
|
m_Server.DeleteSession (shared_from_this ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -192,11 +192,11 @@ namespace transport
|
||||||
m_Server.DeleteSession (shared_from_this ());
|
m_Server.DeleteSession (shared_from_this ());
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_RELAY_REQUEST:
|
case PAYLOAD_TYPE_RELAY_REQUEST:
|
||||||
LogPrint (eLogDebug, "SSU: relay request received");
|
LogPrint (eLogDebug, "SSU: Relay request received");
|
||||||
ProcessRelayRequest (buf + headerSize, len - headerSize, senderEndpoint);
|
ProcessRelayRequest (buf + headerSize, len - headerSize, senderEndpoint);
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_RELAY_INTRO:
|
case PAYLOAD_TYPE_RELAY_INTRO:
|
||||||
LogPrint (eLogDebug, "SSU: relay intro received");
|
LogPrint (eLogDebug, "SSU: Relay intro received");
|
||||||
ProcessRelayIntro (buf + headerSize, len - headerSize);
|
ProcessRelayIntro (buf + headerSize, len - headerSize);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -206,7 +206,7 @@ namespace transport
|
||||||
|
|
||||||
void SSUSession::ProcessSessionRequest (const uint8_t * buf, size_t len)
|
void SSUSession::ProcessSessionRequest (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU message: session request");
|
LogPrint (eLogDebug, "SSU message: Session request");
|
||||||
bool sendRelayTag = true;
|
bool sendRelayTag = true;
|
||||||
auto headerSize = sizeof (SSUHeader);
|
auto headerSize = sizeof (SSUHeader);
|
||||||
if (((SSUHeader *)buf)->IsExtendedOptions ())
|
if (((SSUHeader *)buf)->IsExtendedOptions ())
|
||||||
|
@ -222,7 +222,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
if (headerSize >= len)
|
if (headerSize >= len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Session request header size ", headerSize, " exceeds packet length ", len);
|
LogPrint (eLogError, "SSU: Session request header size ", headerSize, " exceeds packet length ", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_DHKeysPair)
|
if (!m_DHKeysPair)
|
||||||
|
@ -243,13 +243,13 @@ namespace transport
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint (eLogDebug, "SSU message: session created");
|
LogPrint (eLogDebug, "SSU message: Session created");
|
||||||
m_ConnectTimer.cancel (); // connect timer
|
m_ConnectTimer.cancel (); // connect timer
|
||||||
SignedData s; // x,y, our IP, our port, remote IP, remote port, relayTag, signed on time
|
SignedData s; // x,y, our IP, our port, remote IP, remote port, relayTag, signed on time
|
||||||
auto headerSize = GetSSUHeaderSize (buf);
|
auto headerSize = GetSSUHeaderSize (buf);
|
||||||
if (headerSize >= len)
|
if (headerSize >= len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Session created header size ", headerSize, " exceeds packet length ", len);
|
LogPrint (eLogError, "SSU: Session created header size ", headerSize, " exceeds packet length ", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t * payload = buf + headerSize;
|
uint8_t * payload = buf + headerSize;
|
||||||
|
@ -280,7 +280,7 @@ namespace transport
|
||||||
uint32_t signedOnTime = bufbe32toh(payload);
|
uint32_t signedOnTime = bufbe32toh(payload);
|
||||||
if (signedOnTime < ts - SSU_CLOCK_SKEW || signedOnTime > ts + SSU_CLOCK_SKEW)
|
if (signedOnTime < ts - SSU_CLOCK_SKEW || signedOnTime > ts + SSU_CLOCK_SKEW)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: clock skew detected ", (int)ts - signedOnTime, ". Check your clock");
|
LogPrint (eLogError, "SSU: Clock skew detected ", (int)ts - signedOnTime, ". Check your clock!");
|
||||||
i2p::context.SetError (eRouterErrorClockSkew);
|
i2p::context.SetError (eRouterErrorClockSkew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU: message 'created' signature verification failed");
|
LogPrint (eLogError, "SSU: Message 'created' signature verification failed");
|
||||||
Failed ();
|
Failed ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -647,7 +647,7 @@ namespace transport
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, isV4 ? 64 : 80, introKey, iv, introKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, isV4 ? 64 : 80, introKey, iv, introKey);
|
||||||
m_Server.Send (buf, isV4 ? 64 : 80, from);
|
m_Server.Send (buf, isV4 ? 64 : 80, from);
|
||||||
}
|
}
|
||||||
LogPrint (eLogDebug, "SSU: relay response sent");
|
LogPrint (eLogDebug, "SSU: Relay response sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::SendRelayIntro (std::shared_ptr<SSUSession> session, const boost::asio::ip::udp::endpoint& from)
|
void SSUSession::SendRelayIntro (std::shared_ptr<SSUSession> session, const boost::asio::ip::udp::endpoint& from)
|
||||||
|
@ -683,7 +683,7 @@ namespace transport
|
||||||
RAND_bytes (iv, 16); // random iv
|
RAND_bytes (iv, 16); // random iv
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_INTRO, buf, isV4 ? 48 : 64, session->m_SessionKey, iv, session->m_MacKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_INTRO, buf, isV4 ? 48 : 64, session->m_SessionKey, iv, session->m_MacKey);
|
||||||
m_Server.Send (buf, isV4 ? 48 : 64, session->m_RemoteEndpoint);
|
m_Server.Send (buf, isV4 ? 48 : 64, session->m_RemoteEndpoint);
|
||||||
LogPrint (eLogDebug, "SSU: relay intro sent");
|
LogPrint (eLogDebug, "SSU: Relay intro sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::ProcessRelayResponse (const uint8_t * buf, size_t len)
|
void SSUSession::ProcessRelayResponse (const uint8_t * buf, size_t len)
|
||||||
|
@ -872,7 +872,7 @@ namespace transport
|
||||||
if (!IsOutgoing ()) // incoming session
|
if (!IsOutgoing ()) // incoming session
|
||||||
ScheduleConnectTimer ();
|
ScheduleConnectTimer ();
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "SSU: wait for connect for outgoing session");
|
LogPrint (eLogError, "SSU: Wait for connect for outgoing session");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::ScheduleConnectTimer ()
|
void SSUSession::ScheduleConnectTimer ()
|
||||||
|
@ -888,7 +888,7 @@ namespace transport
|
||||||
if (!ecode)
|
if (!ecode)
|
||||||
{
|
{
|
||||||
// timeout expired
|
// timeout expired
|
||||||
LogPrint (eLogWarning, "SSU: session with ", m_RemoteEndpoint, " was not established after ", SSU_CONNECT_TIMEOUT, " seconds");
|
LogPrint (eLogWarning, "SSU: Session with ", m_RemoteEndpoint, " was not established after ", SSU_CONNECT_TIMEOUT, " seconds");
|
||||||
Failed ();
|
Failed ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (m_Server.GetPeerTestSession (nonce) == shared_from_this ()) // Alice-Bob
|
if (m_Server.GetPeerTestSession (nonce) == shared_from_this ()) // Alice-Bob
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Bob. We are Alice");
|
LogPrint (eLogDebug, "SSU: Peer test from Bob. We are Alice");
|
||||||
if (IsV6 ())
|
if (IsV6 ())
|
||||||
{
|
{
|
||||||
if (i2p::context.GetStatusV6 () == eRouterStatusTesting)
|
if (i2p::context.GetStatusV6 () == eRouterStatusTesting)
|
||||||
|
@ -1040,9 +1040,9 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: first peer test from Charlie. We are Alice");
|
LogPrint (eLogDebug, "SSU: First peer test from Charlie. We are Alice");
|
||||||
if (m_State == eSessionStateEstablished)
|
if (m_State == eSessionStateEstablished)
|
||||||
LogPrint (eLogWarning, "SSU: first peer test from Charlie through established session. We are Alice");
|
LogPrint (eLogWarning, "SSU: First peer test from Charlie through established session. We are Alice");
|
||||||
if (IsV6 ())
|
if (IsV6 ())
|
||||||
i2p::context.SetStatusV6 (eRouterStatusOK);
|
i2p::context.SetStatusV6 (eRouterStatusOK);
|
||||||
else
|
else
|
||||||
|
@ -1055,11 +1055,11 @@ namespace transport
|
||||||
case ePeerTestParticipantAlice2:
|
case ePeerTestParticipantAlice2:
|
||||||
{
|
{
|
||||||
if (m_Server.GetPeerTestSession (nonce) == shared_from_this ()) // Alice-Bob
|
if (m_Server.GetPeerTestSession (nonce) == shared_from_this ()) // Alice-Bob
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Bob. We are Alice");
|
LogPrint (eLogDebug, "SSU: Peer test from Bob. We are Alice");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// peer test successive
|
// peer test successive
|
||||||
LogPrint (eLogDebug, "SSU: second peer test from Charlie. We are Alice");
|
LogPrint (eLogDebug, "SSU: Second peer test from Charlie. We are Alice");
|
||||||
if (IsV6 ())
|
if (IsV6 ())
|
||||||
i2p::context.SetStatusV6 (eRouterStatusOK);
|
i2p::context.SetStatusV6 (eRouterStatusOK);
|
||||||
else
|
else
|
||||||
|
@ -1070,7 +1070,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
case ePeerTestParticipantBob:
|
case ePeerTestParticipantBob:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Charlie. We are Bob");
|
LogPrint (eLogDebug, "SSU: Peer test from Charlie. We are Bob");
|
||||||
auto session = m_Server.GetPeerTestSession (nonce); // session with Alice from PeerTest
|
auto session = m_Server.GetPeerTestSession (nonce); // session with Alice from PeerTest
|
||||||
if (session && session->m_State == eSessionStateEstablished)
|
if (session && session->m_State == eSessionStateEstablished)
|
||||||
{
|
{
|
||||||
|
@ -1082,7 +1082,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
case ePeerTestParticipantCharlie:
|
case ePeerTestParticipantCharlie:
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Alice. We are Charlie");
|
LogPrint (eLogDebug, "SSU: Peer test from Alice. We are Charlie");
|
||||||
SendPeerTest (nonce, senderEndpoint.address (), senderEndpoint.port (), introKey); // to Alice with her actual address
|
SendPeerTest (nonce, senderEndpoint.address (), senderEndpoint.port (), introKey); // to Alice with her actual address
|
||||||
m_Server.RemovePeerTest (nonce); // nonce has been used
|
m_Server.RemovePeerTest (nonce); // nonce has been used
|
||||||
break;
|
break;
|
||||||
|
@ -1095,7 +1095,7 @@ namespace transport
|
||||||
// new test
|
// new test
|
||||||
if (port)
|
if (port)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Bob. We are Charlie");
|
LogPrint (eLogDebug, "SSU: Peer test from Bob. We are Charlie");
|
||||||
Send (PAYLOAD_TYPE_PEER_TEST, buf, len); // back to Bob
|
Send (PAYLOAD_TYPE_PEER_TEST, buf, len); // back to Bob
|
||||||
if (!addr.is_unspecified () && !i2p::util::net::IsInReservedRange(addr))
|
if (!addr.is_unspecified () && !i2p::util::net::IsInReservedRange(addr))
|
||||||
{
|
{
|
||||||
|
@ -1105,7 +1105,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU: peer test from Alice. We are Bob");
|
LogPrint (eLogDebug, "SSU: Peer test from Alice. We are Bob");
|
||||||
auto session = senderEndpoint.address ().is_v4 () ? m_Server.GetRandomEstablishedV4Session (shared_from_this ()) : m_Server.GetRandomEstablishedV6Session (shared_from_this ()); // Charlie
|
auto session = senderEndpoint.address ().is_v4 () ? m_Server.GetRandomEstablishedV4Session (shared_from_this ()) : m_Server.GetRandomEstablishedV6Session (shared_from_this ()); // Charlie
|
||||||
if (session)
|
if (session)
|
||||||
{
|
{
|
||||||
|
@ -1115,7 +1115,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "SSU: unexpected peer test");
|
LogPrint (eLogError, "SSU: Unexpected peer test");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1188,7 @@ namespace transport
|
||||||
void SSUSession::SendPeerTest ()
|
void SSUSession::SendPeerTest ()
|
||||||
{
|
{
|
||||||
// we are Alice
|
// we are Alice
|
||||||
LogPrint (eLogDebug, "SSU: sending peer test");
|
LogPrint (eLogDebug, "SSU: Initiating peer test");
|
||||||
auto address = IsV6 () ? i2p::context.GetRouterInfo ().GetSSUV6Address () : i2p::context.GetRouterInfo ().GetSSUAddress (true);
|
auto address = IsV6 () ? i2p::context.GetRouterInfo ().GetSSUV6Address () : i2p::context.GetRouterInfo ().GetSSUAddress (true);
|
||||||
if (!address)
|
if (!address)
|
||||||
{
|
{
|
||||||
|
@ -1233,9 +1233,9 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: exception while sending session destoroyed: ", ex.what ());
|
LogPrint (eLogWarning, "SSU: Exception while sending session destroyed: ", ex.what ());
|
||||||
}
|
}
|
||||||
LogPrint (eLogDebug, "SSU: session destroyed sent");
|
LogPrint (eLogDebug, "SSU: Session destroyed sent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1247,7 +1247,7 @@ namespace transport
|
||||||
if (paddingSize > 0) msgSize += (16 - paddingSize);
|
if (paddingSize > 0) msgSize += (16 - paddingSize);
|
||||||
if (msgSize > SSU_MTU_V4)
|
if (msgSize > SSU_MTU_V4)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: payload size ", msgSize, " exceeds MTU");
|
LogPrint (eLogWarning, "SSU: Payload size ", msgSize, " exceeds MTU");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy (buf + sizeof (SSUHeader), payload, len);
|
memcpy (buf + sizeof (SSUHeader), payload, len);
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace transport
|
||||||
m_Queue.push (pair);
|
m_Queue.push (pair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint(eLogError, "Transports: return null DHKeys");
|
LogPrint(eLogError, "Transports: Return null DHKeys");
|
||||||
}
|
}
|
||||||
|
|
||||||
Transports transports;
|
Transports transports;
|
||||||
|
@ -192,10 +192,10 @@ namespace transport
|
||||||
i2p::context.SetStatus (eRouterStatusProxy);
|
i2p::context.SetStatus (eRouterStatusProxy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint(eLogError, "Transports: unsupported NTCP2 proxy URL ", ntcp2proxy);
|
LogPrint(eLogError, "Transports: Unsupported NTCP2 proxy URL ", ntcp2proxy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint(eLogError, "Transports: invalid NTCP2 proxy url ", ntcp2proxy);
|
LogPrint(eLogError, "Transports: invalid NTCP2 proxy URL ", ntcp2proxy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_NTCP2Server = new NTCP2Server ();
|
m_NTCP2Server = new NTCP2Server ();
|
||||||
|
@ -335,7 +335,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Transports: runtime exception: ", ex.what ());
|
LogPrint (eLogError, "Transports: Runtime exception: ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Transports: delayed messages queue size to ",
|
LogPrint (eLogWarning, "Transports: Delayed messages queue size to ",
|
||||||
ident.ToBase64 (), " exceeds ", MAX_NUM_DELAYED_MESSAGES);
|
ident.ToBase64 (), " exceeds ", MAX_NUM_DELAYED_MESSAGES);
|
||||||
std::unique_lock<std::mutex> l(m_PeersMutex);
|
std::unique_lock<std::mutex> l(m_PeersMutex);
|
||||||
m_Peers.erase (it);
|
m_Peers.erase (it);
|
||||||
|
@ -680,7 +680,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
if(RoutesRestricted() && ! IsRestrictedPeer(ident)) {
|
if(RoutesRestricted() && ! IsRestrictedPeer(ident)) {
|
||||||
// not trusted
|
// not trusted
|
||||||
LogPrint(eLogWarning, "Transports: closing untrusted inbound connection from ", ident.ToBase64());
|
LogPrint(eLogWarning, "Transports: Closing untrusted inbound connection from ", ident.ToBase64());
|
||||||
session->Done();
|
session->Done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace tunnel
|
||||||
SHA256(fragment, TUNNEL_DATA_MSG_SIZE -(fragment - msg->GetPayload ()) + 16, hash); // payload + iv
|
SHA256(fragment, TUNNEL_DATA_MSG_SIZE -(fragment - msg->GetPayload ()) + 16, hash); // payload + iv
|
||||||
if (memcmp (hash, decrypted, 4))
|
if (memcmp (hash, decrypted, 4))
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "TunnelMessage: checksum verification failed");
|
LogPrint (eLogError, "TunnelMessage: Checksum verification failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// process fragments
|
// process fragments
|
||||||
|
@ -118,7 +118,7 @@ namespace tunnel
|
||||||
// check message size
|
// check message size
|
||||||
if (msg->len > msg->maxLen)
|
if (msg->len > msg->maxLen)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "TunnelMessage: fragment is too long ", (int)size);
|
LogPrint (eLogError, "TunnelMessage: Fragment is too long ", (int)size);
|
||||||
m_CurrentMsgID = 0; m_CurrentMessage.data = nullptr;
|
m_CurrentMsgID = 0; m_CurrentMessage.data = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ namespace tunnel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "TunnelMessage: zero not found");
|
LogPrint (eLogError, "TunnelMessage: Zero not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunnelEndpoint::HandleFollowOnFragment (uint32_t msgID, bool isLastFragment,
|
void TunnelEndpoint::HandleFollowOnFragment (uint32_t msgID, bool isLastFragment,
|
||||||
|
@ -264,7 +264,7 @@ namespace tunnel
|
||||||
std::unique_ptr<Fragment> f(new Fragment (isLastFragment, i2p::util::GetMillisecondsSinceEpoch (), size));
|
std::unique_ptr<Fragment> f(new Fragment (isLastFragment, i2p::util::GetMillisecondsSinceEpoch (), size));
|
||||||
memcpy (f->data.data (), fragment, size);
|
memcpy (f->data.data (), fragment, size);
|
||||||
if (!m_OutOfSequenceFragments.emplace ((uint64_t)msgID << 32 | fragmentNum, std::move (f)).second)
|
if (!m_OutOfSequenceFragments.emplace ((uint64_t)msgID << 32 | fragmentNum, std::move (f)).second)
|
||||||
LogPrint (eLogInfo, "TunnelMessage: duplicate out-of-sequence fragment ", fragmentNum, " of message ", msgID);
|
LogPrint (eLogInfo, "TunnelMessage: Duplicate out-of-sequence fragment ", fragmentNum, " of message ", msgID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunnelEndpoint::HandleOutOfSequenceFragments (uint32_t msgID, TunnelMessageBlockEx& msg)
|
void TunnelEndpoint::HandleOutOfSequenceFragments (uint32_t msgID, TunnelMessageBlockEx& msg)
|
||||||
|
@ -318,11 +318,11 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
if (!m_IsInbound && msg.data->IsExpired ())
|
if (!m_IsInbound && msg.data->IsExpired ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "TunnelMessage: message expired");
|
LogPrint (eLogInfo, "TunnelMessage: Message expired");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t typeID = msg.data->GetTypeID ();
|
uint8_t typeID = msg.data->GetTypeID ();
|
||||||
LogPrint (eLogDebug, "TunnelMessage: handle fragment of ", msg.data->GetLength (), " bytes, msg type ", (int)typeID);
|
LogPrint (eLogDebug, "TunnelMessage: Handle fragment of ", msg.data->GetLength (), " bytes, msg type ", (int)typeID);
|
||||||
// catch RI or reply with new list of routers
|
// catch RI or reply with new list of routers
|
||||||
if ((IsRouterInfoMsg (msg.data) || typeID == eI2NPDatabaseSearchReply) &&
|
if ((IsRouterInfoMsg (msg.data) || typeID == eI2NPDatabaseSearchReply) &&
|
||||||
!m_IsInbound && msg.deliveryType != eDeliveryTypeLocal)
|
!m_IsInbound && msg.deliveryType != eDeliveryTypeLocal)
|
||||||
|
|
|
@ -60,22 +60,22 @@ namespace api
|
||||||
else
|
else
|
||||||
i2p::log::Logger().SendTo (i2p::fs::DataDirPath (i2p::fs::GetAppName () + ".log"));
|
i2p::log::Logger().SendTo (i2p::fs::DataDirPath (i2p::fs::GetAppName () + ".log"));
|
||||||
i2p::log::Logger().Start ();
|
i2p::log::Logger().Start ();
|
||||||
LogPrint(eLogInfo, "API: starting NetDB");
|
LogPrint(eLogInfo, "API: Starting NetDB");
|
||||||
i2p::data::netdb.Start();
|
i2p::data::netdb.Start();
|
||||||
LogPrint(eLogInfo, "API: starting Transports");
|
LogPrint(eLogInfo, "API: Starting Transports");
|
||||||
i2p::transport::transports.Start();
|
i2p::transport::transports.Start();
|
||||||
LogPrint(eLogInfo, "API: starting Tunnels");
|
LogPrint(eLogInfo, "API: Starting Tunnels");
|
||||||
i2p::tunnel::tunnels.Start();
|
i2p::tunnel::tunnels.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopI2P ()
|
void StopI2P ()
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo, "API: shutting down");
|
LogPrint(eLogInfo, "API: Shutting down");
|
||||||
LogPrint(eLogInfo, "API: stopping Tunnels");
|
LogPrint(eLogInfo, "API: Stopping Tunnels");
|
||||||
i2p::tunnel::tunnels.Stop();
|
i2p::tunnel::tunnels.Stop();
|
||||||
LogPrint(eLogInfo, "API: stopping Transports");
|
LogPrint(eLogInfo, "API: Stopping Transports");
|
||||||
i2p::transport::transports.Stop();
|
i2p::transport::transports.Stop();
|
||||||
LogPrint(eLogInfo, "API: stopping NetDB");
|
LogPrint(eLogInfo, "API: Stopping NetDB");
|
||||||
i2p::data::netdb.Stop();
|
i2p::data::netdb.Stop();
|
||||||
i2p::log::Logger().Stop ();
|
i2p::log::Logger().Stop ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,7 +377,7 @@ namespace net
|
||||||
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6)
|
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
LogPrint(eLogError, "NetIface: cannot get address by interface name, not implemented on WIN32");
|
LogPrint(eLogError, "NetIface: Cannot get address by interface name, not implemented on WIN32");
|
||||||
if(ipv6)
|
if(ipv6)
|
||||||
return boost::asio::ip::address::from_string("::1");
|
return boost::asio::ip::address::from_string("::1");
|
||||||
else
|
else
|
||||||
|
@ -413,10 +413,10 @@ namespace net
|
||||||
if(ipv6)
|
if(ipv6)
|
||||||
{
|
{
|
||||||
fallback = "::1";
|
fallback = "::1";
|
||||||
LogPrint(eLogWarning, "NetIface: cannot find ipv6 address for interface ", ifname);
|
LogPrint(eLogWarning, "NetIface: Can't find ipv6 address for interface ", ifname);
|
||||||
} else {
|
} else {
|
||||||
fallback = "127.0.0.1";
|
fallback = "127.0.0.1";
|
||||||
LogPrint(eLogWarning, "NetIface: cannot find ipv4 address for interface ", ifname);
|
LogPrint(eLogWarning, "NetIface: Can't find ipv4 address for interface ", ifname);
|
||||||
}
|
}
|
||||||
return boost::asio::ip::address::from_string(fallback);
|
return boost::asio::ip::address::from_string(fallback);
|
||||||
#endif
|
#endif
|
||||||
|
@ -479,7 +479,7 @@ namespace net
|
||||||
}
|
}
|
||||||
pCurrAddresses = pCurrAddresses->Next;
|
pCurrAddresses = pCurrAddresses->Next;
|
||||||
}
|
}
|
||||||
LogPrint(eLogWarning, "NetIface: interface with yggdrasil network address not found");
|
LogPrint(eLogWarning, "NetIface: Interface with yggdrasil network address not found");
|
||||||
FREE(pAddresses);
|
FREE(pAddresses);
|
||||||
return boost::asio::ip::address_v6 ();
|
return boost::asio::ip::address_v6 ();
|
||||||
#else
|
#else
|
||||||
|
@ -504,7 +504,7 @@ namespace net
|
||||||
cur = cur->ifa_next;
|
cur = cur->ifa_next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogPrint(eLogWarning, "NetIface: interface with yggdrasil network address not found");
|
LogPrint(eLogWarning, "NetIface: Interface with yggdrasil network address not found");
|
||||||
if(addrs) freeifaddrs(addrs);
|
if(addrs) freeifaddrs(addrs);
|
||||||
return boost::asio::ip::address_v6 ();
|
return boost::asio::ip::address_v6 ();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace client
|
||||||
std::string path = storage.Path( address->GetIdentHash().ToBase32() );
|
std::string path = storage.Path( address->GetIdentHash().ToBase32() );
|
||||||
std::ofstream f (path, std::ofstream::binary | std::ofstream::out);
|
std::ofstream f (path, std::ofstream::binary | std::ofstream::out);
|
||||||
if (!f.is_open ()) {
|
if (!f.is_open ()) {
|
||||||
LogPrint (eLogError, "Addressbook: can't open file ", path);
|
LogPrint (eLogError, "Addressbook: Can't open file ", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t len = address->GetFullLen ();
|
size_t len = address->GetFullLen ();
|
||||||
|
@ -169,7 +169,7 @@ namespace client
|
||||||
LogPrint(eLogWarning, "Addressbook: Can't open ", indexPath);
|
LogPrint(eLogWarning, "Addressbook: Can't open ", indexPath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LogPrint(eLogInfo, "Addressbook: using index file ", indexPath);
|
LogPrint(eLogInfo, "Addressbook: Using index file ", indexPath);
|
||||||
LogPrint (eLogInfo, "Addressbook: ", num, " addresses loaded from storage");
|
LogPrint (eLogInfo, "Addressbook: ", num, " addresses loaded from storage");
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
@ -187,7 +187,7 @@ namespace client
|
||||||
{
|
{
|
||||||
if (addresses.empty())
|
if (addresses.empty())
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning, "Addressbook: not saving empty addressbook");
|
LogPrint(eLogWarning, "Addressbook: Not saving empty addressbook");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ namespace client
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Addressbook: invalid address ", it.first);
|
LogPrint (eLogWarning, "Addressbook: Invalid address ", it.first);
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Addressbook: ", num, " addresses saved");
|
LogPrint (eLogInfo, "Addressbook: ", num, " addresses saved");
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ namespace client
|
||||||
|
|
||||||
void AddressBookFilesystemStorage::ResetEtags ()
|
void AddressBookFilesystemStorage::ResetEtags ()
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Addressbook: resetting eTags");
|
LogPrint (eLogError, "Addressbook: Resetting eTags");
|
||||||
for (boost::filesystem::directory_iterator it (etagsPath); it != boost::filesystem::directory_iterator (); ++it)
|
for (boost::filesystem::directory_iterator it (etagsPath); it != boost::filesystem::directory_iterator (); ++it)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_regular_file (it->status ()))
|
if (!boost::filesystem::is_regular_file (it->status ()))
|
||||||
|
@ -334,17 +334,17 @@ namespace client
|
||||||
}
|
}
|
||||||
if (m_IsDownloading)
|
if (m_IsDownloading)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Addressbook: subscriptions are downloading, abort");
|
LogPrint (eLogInfo, "Addressbook: Subscriptions are downloading, abort");
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
{
|
{
|
||||||
if (!m_IsDownloading)
|
if (!m_IsDownloading)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Addressbook: subscriptions download complete");
|
LogPrint (eLogInfo, "Addressbook: Subscriptions download complete");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for (std::chrono::seconds (1)); // wait for 1 seconds
|
std::this_thread::sleep_for (std::chrono::seconds (1)); // wait for 1 seconds
|
||||||
}
|
}
|
||||||
LogPrint (eLogError, "Addressbook: subscription download timeout");
|
LogPrint (eLogError, "Addressbook: Subscription download timeout");
|
||||||
m_IsDownloading = false;
|
m_IsDownloading = false;
|
||||||
}
|
}
|
||||||
if (m_Storage)
|
if (m_Storage)
|
||||||
|
@ -397,7 +397,7 @@ namespace client
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
m_Addresses[address] = std::make_shared<Address>(jump.substr (0, pos));
|
m_Addresses[address] = std::make_shared<Address>(jump.substr (0, pos));
|
||||||
LogPrint (eLogInfo, "Addressbook: added ", address," -> ", jump);
|
LogPrint (eLogInfo, "Addressbook: Added ", address," -> ", jump);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -407,10 +407,10 @@ namespace client
|
||||||
{
|
{
|
||||||
m_Storage->AddAddress (ident);
|
m_Storage->AddAddress (ident);
|
||||||
m_Addresses[address] = std::make_shared<Address>(ident->GetIdentHash ());
|
m_Addresses[address] = std::make_shared<Address>(ident->GetIdentHash ());
|
||||||
LogPrint (eLogInfo, "Addressbook: added ", address," -> ", ToAddress(ident->GetIdentHash ()));
|
LogPrint (eLogInfo, "Addressbook: Added ", address," -> ", ToAddress(ident->GetIdentHash ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Addressbook: malformed address ", jump);
|
LogPrint (eLogError, "Addressbook: Malformed address ", jump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ namespace client
|
||||||
|
|
||||||
auto ident = std::make_shared<i2p::data::IdentityEx> ();
|
auto ident = std::make_shared<i2p::data::IdentityEx> ();
|
||||||
if (!ident->FromBase64(addr)) {
|
if (!ident->FromBase64(addr)) {
|
||||||
LogPrint (eLogError, "Addressbook: malformed address ", addr, " for ", name);
|
LogPrint (eLogError, "Addressbook: Malformed address ", addr, " for ", name);
|
||||||
incomplete = f.eof ();
|
incomplete = f.eof ();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ namespace client
|
||||||
it->second->identHash = ident->GetIdentHash ();
|
it->second->identHash = ident->GetIdentHash ();
|
||||||
m_Storage->AddAddress (ident);
|
m_Storage->AddAddress (ident);
|
||||||
m_Storage->RemoveAddress (it->second->identHash);
|
m_Storage->RemoveAddress (it->second->identHash);
|
||||||
LogPrint (eLogInfo, "Addressbook: updated host: ", name);
|
LogPrint (eLogInfo, "Addressbook: Updated host: ", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -494,7 +494,7 @@ namespace client
|
||||||
m_Addresses.emplace (name, std::make_shared<Address>(ident->GetIdentHash ()));
|
m_Addresses.emplace (name, std::make_shared<Address>(ident->GetIdentHash ()));
|
||||||
m_Storage->AddAddress (ident);
|
m_Storage->AddAddress (ident);
|
||||||
if (is_update)
|
if (is_update)
|
||||||
LogPrint (eLogInfo, "Addressbook: added new host: ", name);
|
LogPrint (eLogInfo, "Addressbook: Added new host: ", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -523,7 +523,7 @@ namespace client
|
||||||
if (s.empty () || s[0] == '#') continue; // skip empty line or comment
|
if (s.empty () || s[0] == '#') continue; // skip empty line or comment
|
||||||
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
|
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions URLs loaded");
|
||||||
LogPrint (eLogWarning, "Addressbook: subscriptions.txt usage is deprecated, use config file instead");
|
LogPrint (eLogWarning, "Addressbook: subscriptions.txt usage is deprecated, use config file instead");
|
||||||
}
|
}
|
||||||
else if (!i2p::config::IsDefault("addressbook.subscriptions"))
|
else if (!i2p::config::IsDefault("addressbook.subscriptions"))
|
||||||
|
@ -538,11 +538,11 @@ namespace client
|
||||||
if (s.empty () || s[0] == '#') continue; // skip empty line or comment
|
if (s.empty () || s[0] == '#') continue; // skip empty line or comment
|
||||||
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
|
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions URLs loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Addressbook: subscriptions already loaded");
|
LogPrint (eLogError, "Addressbook: Subscriptions already loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBook::LoadLocal ()
|
void AddressBook::LoadLocal ()
|
||||||
|
@ -627,7 +627,7 @@ namespace client
|
||||||
this, std::placeholders::_1));
|
this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Addressbook: can't start subscriptions: missing shared local destination");
|
LogPrint (eLogError, "Addressbook: Can't start subscriptions: missing shared local destination");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBook::StopSubscriptions ()
|
void AddressBook::StopSubscriptions ()
|
||||||
|
@ -642,7 +642,7 @@ namespace client
|
||||||
{
|
{
|
||||||
auto dest = i2p::client::context.GetSharedLocalDestination ();
|
auto dest = i2p::client::context.GetSharedLocalDestination ();
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
LogPrint(eLogWarning, "Addressbook: missing local destination, skip subscription update");
|
LogPrint(eLogWarning, "Addressbook: Missing local destination, skip subscription update");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_IsDownloading && dest->IsReady ())
|
if (!m_IsDownloading && dest->IsReady ())
|
||||||
|
@ -788,7 +788,7 @@ namespace client
|
||||||
LogPrint (eLogInfo, "Addressbook: Downloading hosts database from ", m_Link);
|
LogPrint (eLogInfo, "Addressbook: Downloading hosts database from ", m_Link);
|
||||||
if (!url.parse(m_Link))
|
if (!url.parse(m_Link))
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: failed to parse url: ", m_Link);
|
LogPrint(eLogError, "Addressbook: Failed to parse URL: ", m_Link);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto addr = m_Book.GetAddress (url.host);
|
auto addr = m_Book.GetAddress (url.host);
|
||||||
|
@ -827,7 +827,7 @@ namespace client
|
||||||
}
|
}
|
||||||
if (m_Etag.empty() && m_LastModified.empty()) {
|
if (m_Etag.empty() && m_LastModified.empty()) {
|
||||||
m_Book.GetEtag (m_Ident, m_Etag, m_LastModified);
|
m_Book.GetEtag (m_Ident, m_Etag, m_LastModified);
|
||||||
LogPrint (eLogDebug, "Addressbook: loaded for ", url.host, ": ETag: ", m_Etag, ", Last-Modified: ", m_LastModified);
|
LogPrint (eLogDebug, "Addressbook: Loaded for ", url.host, ": ETag: ", m_Etag, ", Last-Modified: ", m_LastModified);
|
||||||
}
|
}
|
||||||
/* save url parts for later use */
|
/* save url parts for later use */
|
||||||
std::string dest_host = url.host;
|
std::string dest_host = url.host;
|
||||||
|
@ -872,7 +872,7 @@ namespace client
|
||||||
// wait 1 more second
|
// wait 1 more second
|
||||||
if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT + 1)) == std::cv_status::timeout)
|
if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT + 1)) == std::cv_status::timeout)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Addressbook: subscriptions request timeout expired");
|
LogPrint (eLogError, "Addressbook: Subscriptions request timeout expired");
|
||||||
numAttempts++;
|
numAttempts++;
|
||||||
if (numAttempts > 5) end = true;
|
if (numAttempts > 5) end = true;
|
||||||
}
|
}
|
||||||
|
@ -885,35 +885,35 @@ namespace client
|
||||||
int res_head_len = res.parse(response);
|
int res_head_len = res.parse(response);
|
||||||
if (res_head_len < 0)
|
if (res_head_len < 0)
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: can't parse http response from ", dest_host);
|
LogPrint(eLogError, "Addressbook: Can't parse HTTP response from ", dest_host);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (res_head_len == 0)
|
if (res_head_len == 0)
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: incomplete http response from ", dest_host, ", interrupted by timeout");
|
LogPrint(eLogError, "Addressbook: Incomplete HTTP response from ", dest_host, ", interrupted by timeout");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* assert: res_head_len > 0 */
|
/* assert: res_head_len > 0 */
|
||||||
response.erase(0, res_head_len);
|
response.erase(0, res_head_len);
|
||||||
if (res.code == 304)
|
if (res.code == 304)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Addressbook: no updates from ", dest_host, ", code 304");
|
LogPrint (eLogInfo, "Addressbook: No updates from ", dest_host, ", code 304");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (res.code != 200)
|
if (res.code != 200)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Adressbook: can't get updates from ", dest_host, ", response code ", res.code);
|
LogPrint (eLogWarning, "Adressbook: Can't get updates from ", dest_host, ", response code ", res.code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int len = res.content_length();
|
int len = res.content_length();
|
||||||
if (response.empty())
|
if (response.empty())
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: empty response from ", dest_host, ", expected ", len, " bytes");
|
LogPrint(eLogError, "Addressbook: Empty response from ", dest_host, ", expected ", len, " bytes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!res.is_gzipped () && len > 0 && len != (int) response.length())
|
if (!res.is_gzipped () && len > 0 && len != (int) response.length())
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: response size mismatch, expected: ", len, ", got: ", response.length(), "bytes");
|
LogPrint(eLogError, "Addressbook: Response size mismatch, expected: ", len, ", got: ", response.length(), "bytes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* assert: res.code == 200 */
|
/* assert: res.code == 200 */
|
||||||
|
@ -934,13 +934,13 @@ namespace client
|
||||||
inflator.Inflate ((const uint8_t *) response.data(), response.length(), out);
|
inflator.Inflate ((const uint8_t *) response.data(), response.length(), out);
|
||||||
if (out.fail())
|
if (out.fail())
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Addressbook: can't gunzip http response");
|
LogPrint(eLogError, "Addressbook: Can't gunzip http response");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
response = out.str();
|
response = out.str();
|
||||||
}
|
}
|
||||||
std::stringstream ss(response);
|
std::stringstream ss(response);
|
||||||
LogPrint (eLogInfo, "Addressbook: got update from ", dest_host);
|
LogPrint (eLogInfo, "Addressbook: Got update from ", dest_host);
|
||||||
m_Book.LoadHostsFromStream (ss, true);
|
m_Book.LoadHostsFromStream (ss, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -880,7 +880,7 @@ namespace client
|
||||||
session->SendVersion ();
|
session->SendVersion ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "BOB: accept error: ", ecode.message ());
|
LogPrint (eLogError, "BOB: Accept error: ", ecode.message ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,7 +567,7 @@ namespace client
|
||||||
Connect (leaseSet);
|
Connect (leaseSet);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SAM: destination to connect not found");
|
LogPrint (eLogError, "SAM: Destination to connect not found");
|
||||||
SendMessageReply (SAM_STREAM_STATUS_CANT_REACH_PEER, strlen(SAM_STREAM_STATUS_CANT_REACH_PEER), true);
|
SendMessageReply (SAM_STREAM_STATUS_CANT_REACH_PEER, strlen(SAM_STREAM_STATUS_CANT_REACH_PEER), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ namespace client
|
||||||
|
|
||||||
void SAMSocket::ProcessStreamForward (char * buf, size_t len)
|
void SAMSocket::ProcessStreamForward (char * buf, size_t len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SAM: stream forward: ", buf);
|
LogPrint (eLogDebug, "SAM: Stream forward: ", buf);
|
||||||
std::map<std::string, std::string> params;
|
std::map<std::string, std::string> params;
|
||||||
ExtractParams (buf, params);
|
ExtractParams (buf, params);
|
||||||
std::string& id = params[SAM_PARAM_ID];
|
std::string& id = params[SAM_PARAM_ID];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue