[log] update log messages (closes #1693)

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2021-11-27 22:53:53 +03:00
parent 4ecf36fab6
commit 94661f697b
No known key found for this signature in database
GPG key ID: 66F6C87B98EBCFE2
37 changed files with 603 additions and 603 deletions

View file

@ -119,7 +119,7 @@ namespace client
std::string path = storage.Path( address->GetIdentHash().ToBase32() );
std::ofstream f (path, std::ofstream::binary | std::ofstream::out);
if (!f.is_open ()) {
LogPrint (eLogError, "Addressbook: can't open file ", path);
LogPrint (eLogError, "Addressbook: Can't open file ", path);
return;
}
size_t len = address->GetFullLen ();
@ -169,7 +169,7 @@ namespace client
LogPrint(eLogWarning, "Addressbook: Can't open ", indexPath);
return 0;
}
LogPrint(eLogInfo, "Addressbook: using index file ", indexPath);
LogPrint(eLogInfo, "Addressbook: Using index file ", indexPath);
LogPrint (eLogInfo, "Addressbook: ", num, " addresses loaded from storage");
return num;
@ -187,7 +187,7 @@ namespace client
{
if (addresses.empty())
{
LogPrint(eLogWarning, "Addressbook: not saving empty addressbook");
LogPrint(eLogWarning, "Addressbook: Not saving empty addressbook");
return 0;
}
@ -210,7 +210,7 @@ namespace client
num++;
}
else
LogPrint (eLogWarning, "Addressbook: invalid address ", it.first);
LogPrint (eLogWarning, "Addressbook: Invalid address ", it.first);
}
LogPrint (eLogInfo, "Addressbook: ", num, " addresses saved");
}
@ -265,7 +265,7 @@ namespace client
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)
{
if (!boost::filesystem::is_regular_file (it->status ()))
@ -334,17 +334,17 @@ namespace client
}
if (m_IsDownloading)
{
LogPrint (eLogInfo, "Addressbook: subscriptions are downloading, abort");
LogPrint (eLogInfo, "Addressbook: Subscriptions are downloading, abort");
for (int i = 0; i < 30; i++)
{
if (!m_IsDownloading)
{
LogPrint (eLogInfo, "Addressbook: subscriptions download complete");
LogPrint (eLogInfo, "Addressbook: Subscriptions download complete");
break;
}
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;
}
if (m_Storage)
@ -397,7 +397,7 @@ namespace client
if (pos != std::string::npos)
{
m_Addresses[address] = std::make_shared<Address>(jump.substr (0, pos));
LogPrint (eLogInfo, "Addressbook: added ", address," -> ", jump);
LogPrint (eLogInfo, "Addressbook: Added ", address," -> ", jump);
}
else
{
@ -407,10 +407,10 @@ namespace client
{
m_Storage->AddAddress (ident);
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
LogPrint (eLogError, "Addressbook: malformed address ", jump);
LogPrint (eLogError, "Addressbook: Malformed address ", jump);
}
}
@ -473,20 +473,20 @@ namespace client
pos = name.find(".b32.i2p");
if (pos != std::string::npos)
{
LogPrint (eLogError, "Addressbook: skipped adding of b32 address: ", name);
LogPrint (eLogError, "Addressbook: Skipped adding of b32 address: ", name);
continue;
}
pos = name.find(".i2p");
if (pos == std::string::npos)
{
LogPrint (eLogError, "Addressbook: malformed domain: ", name);
LogPrint (eLogError, "Addressbook: Malformed domain: ", name);
continue;
}
auto ident = std::make_shared<i2p::data::IdentityEx> ();
if (!ident->FromBase64(addr)) {
LogPrint (eLogError, "Addressbook: malformed address ", addr, " for ", name);
LogPrint (eLogError, "Addressbook: Malformed address ", addr, " for ", name);
incomplete = f.eof ();
continue;
}
@ -500,7 +500,7 @@ namespace client
it->second->identHash = ident->GetIdentHash ();
m_Storage->AddAddress (ident);
m_Storage->RemoveAddress (it->second->identHash);
LogPrint (eLogInfo, "Addressbook: updated host: ", name);
LogPrint (eLogInfo, "Addressbook: Updated host: ", name);
}
}
else
@ -508,7 +508,7 @@ namespace client
m_Addresses.emplace (name, std::make_shared<Address>(ident->GetIdentHash ()));
m_Storage->AddAddress (ident);
if (is_update)
LogPrint (eLogInfo, "Addressbook: added new host: ", name);
LogPrint (eLogInfo, "Addressbook: Added new host: ", name);
}
}
else
@ -556,7 +556,7 @@ namespace client
}
}
else
LogPrint (eLogError, "Addressbook: subscriptions already loaded");
LogPrint (eLogError, "Addressbook: Subscriptions already loaded");
}
void AddressBook::LoadLocal ()
@ -641,7 +641,7 @@ namespace client
this, std::placeholders::_1));
}
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 ()
@ -656,7 +656,7 @@ namespace client
{
auto dest = i2p::client::context.GetSharedLocalDestination ();
if (!dest) {
LogPrint(eLogWarning, "Addressbook: missing local destination, skip subscription update");
LogPrint(eLogWarning, "Addressbook: Missing local destination, skip subscription update");
return;
}
if (!m_IsDownloading && dest->IsReady ())
@ -664,7 +664,7 @@ namespace client
if (!m_IsLoaded)
{
// download it from default subscription
LogPrint (eLogInfo, "Addressbook: trying to download it from default subscription.");
LogPrint (eLogInfo, "Addressbook: Trying to download it from default subscription.");
std::string defaultSubURL; i2p::config::GetOption("addressbook.defaulturl", defaultSubURL);
if (!m_DefaultSubscription)
m_DefaultSubscription = std::make_shared<AddressBookSubscription>(*this, defaultSubURL);
@ -802,7 +802,7 @@ namespace client
LogPrint (eLogInfo, "Addressbook: Downloading hosts database from ", 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;
}
auto addr = m_Book.GetAddress (url.host);
@ -841,7 +841,7 @@ namespace client
}
if (m_Etag.empty() && m_LastModified.empty()) {
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 */
std::string dest_host = url.host;
@ -886,7 +886,7 @@ namespace client
// wait 1 more second
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++;
if (numAttempts > 5) end = true;
}
@ -899,35 +899,35 @@ namespace client
int res_head_len = res.parse(response);
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;
}
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;
}
/* assert: res_head_len > 0 */
response.erase(0, res_head_len);
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;
}
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;
}
int len = res.content_length();
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;
}
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;
}
/* assert: res.code == 200 */
@ -948,13 +948,13 @@ namespace client
inflator.Inflate ((const uint8_t *) response.data(), response.length(), out);
if (out.fail())
{
LogPrint(eLogError, "Addressbook: can't gunzip http response");
LogPrint(eLogError, "Addressbook: Can't gunzip http response");
return false;
}
response = out.str();
}
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);
return true;
}

View file

@ -68,7 +68,7 @@ namespace client
std::shared_ptr<AddressReceiver> receiver)
{
if (ecode)
LogPrint (eLogError, "BOB: inbound tunnel read error: ", ecode.message ());
LogPrint (eLogError, "BOB: Inbound tunnel read error: ", ecode.message ());
else
{
receiver->bufferOffset += bytes_transferred;
@ -83,7 +83,7 @@ namespace client
auto addr = context.GetAddressBook ().GetAddress (receiver->buffer);
if (!addr)
{
LogPrint (eLogError, "BOB: address ", receiver->buffer, " not found");
LogPrint (eLogError, "BOB: Address ", receiver->buffer, " not found");
return;
}
if (addr->IsIdentHash ())
@ -106,7 +106,7 @@ namespace client
if (receiver->bufferOffset < BOB_COMMAND_BUFFER_SIZE)
ReceiveAddress (receiver);
else
LogPrint (eLogError, "BOB: missing inbound address");
LogPrint (eLogError, "BOB: Missing inbound address");
}
}
}
@ -268,7 +268,7 @@ namespace client
{
if(ecode)
{
LogPrint (eLogError, "BOB: command channel read error: ", ecode.message());
LogPrint (eLogError, "BOB: Command channel read error: ", ecode.message());
if (ecode != boost::asio::error::operation_aborted)
Terminate ();
}
@ -292,7 +292,7 @@ namespace client
}
else
{
LogPrint (eLogError, "BOB: unknown command ", command.c_str());
LogPrint (eLogError, "BOB: Unknown command ", command.c_str());
SendReplyError ("unknown command");
}
}
@ -310,7 +310,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "BOB: command channel send error: ", ecode.message ());
LogPrint (eLogError, "BOB: Command channel send error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ();
}
@ -523,7 +523,7 @@ namespace client
}
catch (std::invalid_argument& ex)
{
LogPrint (eLogWarning, "BOB: newkeys ", ex.what ());
LogPrint (eLogWarning, "BOB: Error on newkeys: ", ex.what ());
}
}
@ -880,7 +880,7 @@ namespace client
session->SendVersion ();
}
else
LogPrint (eLogError, "BOB: accept error: ", ecode.message ());
LogPrint (eLogError, "BOB: Accept error: ", ecode.message ());
}
}
}

View file

@ -65,7 +65,7 @@ namespace client
std::string samAddr; i2p::config::GetOption("sam.address", samAddr);
uint16_t samPort; i2p::config::GetOption("sam.port", samPort);
bool singleThread; i2p::config::GetOption("sam.singlethread", singleThread);
LogPrint(eLogInfo, "Clients: starting SAM bridge at ", samAddr, ":", samPort);
LogPrint(eLogInfo, "Clients: Starting SAM bridge at ", samAddr, ":", samPort);
try
{
m_SamBridge = new SAMBridge (samAddr, samPort, singleThread);
@ -83,7 +83,7 @@ namespace client
if (bob) {
std::string bobAddr; i2p::config::GetOption("bob.address", bobAddr);
uint16_t bobPort; i2p::config::GetOption("bob.port", bobPort);
LogPrint(eLogInfo, "Clients: starting BOB command channel at ", bobAddr, ":", bobPort);
LogPrint(eLogInfo, "Clients: Starting BOB command channel at ", bobAddr, ":", bobPort);
try
{
m_BOBCommandChannel = new BOBCommandChannel (bobAddr, bobPort);
@ -103,7 +103,7 @@ namespace client
std::string i2cpAddr; i2p::config::GetOption("i2cp.address", i2cpAddr);
uint16_t i2cpPort; i2p::config::GetOption("i2cp.port", i2cpPort);
bool singleThread; i2p::config::GetOption("i2cp.singlethread", singleThread);
LogPrint(eLogInfo, "Clients: starting I2CP at ", i2cpAddr, ":", i2cpPort);
LogPrint(eLogInfo, "Clients: Starting I2CP at ", i2cpAddr, ":", i2cpPort);
try
{
m_I2CPServer = new I2CPServer (i2cpAddr, i2cpPort, singleThread);
@ -130,7 +130,7 @@ namespace client
{
if (m_HttpProxy)
{
LogPrint(eLogInfo, "Clients: stopping HTTP Proxy");
LogPrint(eLogInfo, "Clients: Stopping HTTP Proxy");
m_HttpProxy->Stop();
delete m_HttpProxy;
m_HttpProxy = nullptr;
@ -138,7 +138,7 @@ namespace client
if (m_SocksProxy)
{
LogPrint(eLogInfo, "Clients: stopping SOCKS Proxy");
LogPrint(eLogInfo, "Clients: Stopping SOCKS Proxy");
m_SocksProxy->Stop();
delete m_SocksProxy;
m_SocksProxy = nullptr;
@ -146,21 +146,21 @@ namespace client
for (auto& it: m_ClientTunnels)
{
LogPrint(eLogInfo, "Clients: stopping I2P client tunnel on port ", it.first);
LogPrint(eLogInfo, "Clients: Stopping I2P client tunnel on port ", it.first);
it.second->Stop ();
}
m_ClientTunnels.clear ();
for (auto& it: m_ServerTunnels)
{
LogPrint(eLogInfo, "Clients: stopping I2P server tunnel");
LogPrint(eLogInfo, "Clients: Stopping I2P server tunnel");
it.second->Stop ();
}
m_ServerTunnels.clear ();
if (m_SamBridge)
{
LogPrint(eLogInfo, "Clients: stopping SAM bridge");
LogPrint(eLogInfo, "Clients: Stopping SAM bridge");
m_SamBridge->Stop ();
delete m_SamBridge;
m_SamBridge = nullptr;
@ -168,7 +168,7 @@ namespace client
if (m_BOBCommandChannel)
{
LogPrint(eLogInfo, "Clients: stopping BOB command channel");
LogPrint(eLogInfo, "Clients: Stopping BOB command channel");
m_BOBCommandChannel->Stop ();
delete m_BOBCommandChannel;
m_BOBCommandChannel = nullptr;
@ -176,13 +176,13 @@ namespace client
if (m_I2CPServer)
{
LogPrint(eLogInfo, "Clients: stopping I2CP");
LogPrint(eLogInfo, "Clients: Stopping I2CP");
m_I2CPServer->Stop ();
delete m_I2CPServer;
m_I2CPServer = nullptr;
}
LogPrint(eLogInfo, "Clients: stopping AddressBook");
LogPrint(eLogInfo, "Clients: Stopping AddressBook");
m_AddressBook.Stop ();
{
@ -278,7 +278,7 @@ namespace client
s.read ((char *)buf, len);
if(!keys.FromBuffer (buf, len))
{
LogPrint (eLogError, "Clients: failed to load keyfile ", filename);
LogPrint (eLogError, "Clients: Failed to load keyfile ", filename);
success = false;
}
else
@ -287,7 +287,7 @@ namespace client
}
else
{
LogPrint (eLogError, "Clients: can't open file ", fullPath, " Creating new one with signature type ", sigType, " crypto type ", cryptoType);
LogPrint (eLogError, "Clients: Can't open file ", fullPath, " Creating new one with signature type ", sigType, " crypto type ", cryptoType);
keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
std::ofstream f (fullPath, std::ofstream::binary | std::ofstream::out);
size_t len = keys.GetFullLen ();
@ -510,7 +510,7 @@ namespace client
if (tunConf.empty ())
tunConf = i2p::fs::DataDirPath ("tunnels.conf");
LogPrint(eLogDebug, "Clients: tunnels config file: ", tunConf);
LogPrint(eLogDebug, "Clients: Tunnels config file: ", tunConf);
ReadTunnels (tunConf, numClientTunnels, numServerTunnels);
std::string tunDir; i2p::config::GetOption("tunnelsdir", tunDir);
@ -525,7 +525,7 @@ namespace client
for (auto& it: files)
{
if (it.substr(it.size() - 5) != ".conf") continue; // skip files which not ends with ".conf"
LogPrint(eLogDebug, "Clients: tunnels extra config file: ", it);
LogPrint(eLogDebug, "Clients: Tunnels extra config file: ", it);
ReadTunnels (it, numClientTunnels, numServerTunnels);
}
}
@ -754,7 +754,7 @@ namespace client
auto serverTunnel = std::make_shared<I2PUDPServerTunnel>(name, localDestination, localAddress, endpoint, port, gzip);
if(!isUniqueLocal)
{
LogPrint(eLogInfo, "Clients: disabling loopback address mapping");
LogPrint(eLogInfo, "Clients: Disabling loopback address mapping");
serverTunnel->SetUniqueLocal(isUniqueLocal);
}
std::lock_guard<std::mutex> lock(m_ForwardsMutex);
@ -787,7 +787,7 @@ namespace client
serverTunnel->SetLocalAddress (address);
if(!isUniqueLocal)
{
LogPrint(eLogInfo, "Clients: disabling loopback address mapping");
LogPrint(eLogInfo, "Clients: Disabling loopback address mapping");
serverTunnel->SetUniqueLocal(isUniqueLocal);
}
if (accessList.length () > 0)
@ -851,7 +851,7 @@ namespace client
std::string httpOutProxyURL; i2p::config::GetOption("httpproxy.outproxy", httpOutProxyURL);
bool httpAddresshelper; i2p::config::GetOption("httpproxy.addresshelper", httpAddresshelper);
i2p::data::SigningKeyType sigType; i2p::config::GetOption("httpproxy.signaturetype", sigType);
LogPrint(eLogInfo, "Clients: starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort);
LogPrint(eLogInfo, "Clients: Starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort);
if (httpProxyKeys.length () > 0)
{
i2p::data::PrivateKeys keys;
@ -863,7 +863,7 @@ namespace client
if (localDestination) localDestination->Acquire ();
}
else
LogPrint(eLogError, "Clients: failed to load HTTP Proxy key");
LogPrint(eLogError, "Clients: Failed to load HTTP Proxy key");
}
try
{
@ -893,7 +893,7 @@ namespace client
std::string socksOutProxyAddr; i2p::config::GetOption("socksproxy.outproxy", socksOutProxyAddr);
uint16_t socksOutProxyPort; i2p::config::GetOption("socksproxy.outproxyport", socksOutProxyPort);
i2p::data::SigningKeyType sigType; i2p::config::GetOption("socksproxy.signaturetype", sigType);
LogPrint(eLogInfo, "Clients: starting SOCKS Proxy at ", socksProxyAddr, ":", socksProxyPort);
LogPrint(eLogInfo, "Clients: Starting SOCKS Proxy at ", socksProxyAddr, ":", socksProxyPort);
if (httpProxyKeys == socksProxyKeys && m_HttpProxy)
{
localDestination = m_HttpProxy->GetLocalDestination ();
@ -910,7 +910,7 @@ namespace client
if (localDestination) localDestination->Acquire ();
}
else
LogPrint(eLogError, "Clients: failed to load SOCKS Proxy key");
LogPrint(eLogError, "Clients: Failed to load SOCKS Proxy key");
}
try
{

View file

@ -124,9 +124,9 @@ namespace proxy {
void HTTPReqHandler::AsyncSockRead()
{
LogPrint(eLogDebug, "HTTPProxy: async sock read");
LogPrint(eLogDebug, "HTTPProxy: Async sock read");
if (!m_sock) {
LogPrint(eLogError, "HTTPProxy: no socket for read");
LogPrint(eLogError, "HTTPProxy: No socket for read");
return;
}
m_sock->async_read_some(boost::asio::buffer(m_recv_chunk, sizeof(m_recv_chunk)),
@ -138,13 +138,13 @@ namespace proxy {
if (Kill()) return;
if (m_sock)
{
LogPrint(eLogDebug, "HTTPProxy: close sock");
LogPrint(eLogDebug, "HTTPProxy: Close sock");
m_sock->close();
m_sock = nullptr;
}
if(m_proxysock)
{
LogPrint(eLogDebug, "HTTPProxy: close proxysock");
LogPrint(eLogDebug, "HTTPProxy: Close proxysock");
if(m_proxysock->is_open())
m_proxysock->close();
m_proxysock = nullptr;
@ -269,13 +269,13 @@ namespace proxy {
return false; /* need more data */
if (m_req_len < 0) {
LogPrint(eLogError, "HTTPProxy: unable to parse request");
LogPrint(eLogError, "HTTPProxy: Unable to parse request");
GenericProxyError(tr("Invalid request"), tr("Proxy unable to parse your request"));
return true; /* parse error */
}
/* parsing success, now let's look inside request */
LogPrint(eLogDebug, "HTTPProxy: requested: ", m_ClientRequest.uri);
LogPrint(eLogDebug, "HTTPProxy: Requested: ", m_ClientRequest.uri);
m_RequestURL.parse(m_ClientRequest.uri);
bool m_Confirm;
@ -284,14 +284,14 @@ namespace proxy {
{
if (!m_Addresshelper)
{
LogPrint(eLogWarning, "HTTPProxy: addresshelper request rejected");
LogPrint(eLogWarning, "HTTPProxy: Addresshelper request rejected");
GenericProxyError(tr("Invalid request"), tr("addresshelper is not supported"));
return true;
}
if (!i2p::client::context.GetAddressBook ().FindAddress (m_RequestURL.host) || m_Confirm)
{
i2p::client::context.GetAddressBook ().InsertAddress (m_RequestURL.host, jump);
LogPrint (eLogInfo, "HTTPProxy: added address from addresshelper for ", m_RequestURL.host);
LogPrint (eLogInfo, "HTTPProxy: Added address from addresshelper for ", m_RequestURL.host);
std::string full_url = m_RequestURL.to_string();
std::stringstream ss;
ss << tr("Host") <<" " << m_RequestURL.host << " " << tr("added to router's addressbook from helper") << ". ";
@ -375,13 +375,13 @@ namespace proxy {
}
} else {
if(m_OutproxyUrl.size()) {
LogPrint (eLogDebug, "HTTPProxy: use outproxy ", m_OutproxyUrl);
LogPrint (eLogDebug, "HTTPProxy: Using outproxy ", m_OutproxyUrl);
if(m_ProxyURL.parse(m_OutproxyUrl))
ForwardToUpstreamProxy();
else
GenericProxyError(tr("Outproxy failure"), tr("bad outproxy settings"));
} else {
LogPrint (eLogWarning, "HTTPProxy: outproxy failure for ", dest_host, ": no outproxy enabled");
LogPrint (eLogWarning, "HTTPProxy: Outproxy failure for ", dest_host, ": no outproxy enabled");
std::stringstream ss; ss << tr("Host") << " " << dest_host << " " << tr("not inside I2P network, but outproxy is not enabled");
GenericProxyError(tr("Outproxy failure"), ss.str());
}
@ -404,7 +404,7 @@ namespace proxy {
m_send_buf = m_ClientRequest.to_string();
m_send_buf.append(m_recv_buf);
/* connect to destination */
LogPrint(eLogDebug, "HTTPProxy: connecting to host ", dest_host, ":", dest_port);
LogPrint(eLogDebug, "HTTPProxy: Connecting to host ", dest_host, ":", dest_port);
GetOwner()->CreateStream (std::bind (&HTTPReqHandler::HandleStreamRequestComplete,
shared_from_this(), std::placeholders::_1), dest_host, dest_port);
return true;
@ -412,7 +412,7 @@ namespace proxy {
void HTTPReqHandler::ForwardToUpstreamProxy()
{
LogPrint(eLogDebug, "HTTPProxy: forward to upstream");
LogPrint(eLogDebug, "HTTPProxy: Forwarded to upstream");
// build http request
m_ClientRequestURL = m_RequestURL;
@ -490,7 +490,7 @@ namespace proxy {
}
uint16_t port = m_RequestURL.port;
if(!port) port = 80;
LogPrint(eLogDebug, "HTTPProxy: connected to socks upstream");
LogPrint(eLogDebug, "HTTPProxy: Connected to SOCKS upstream");
std::string host = m_RequestURL.host;
std::size_t reqsize = 0;
@ -517,14 +517,14 @@ namespace proxy {
void HTTPReqHandler::HandleSocksProxySendHandshake(const boost::system::error_code & ec, std::size_t bytes_transferred)
{
LogPrint(eLogDebug, "HTTPProxy: upstream socks handshake sent");
LogPrint(eLogDebug, "HTTPProxy: Upstream SOCKS handshake sent");
if(ec) GenericProxyError(tr("Cannot negotiate with socks proxy"), ec.message());
else m_proxysock->async_read_some(boost::asio::buffer(m_socks_buf, 8), std::bind(&HTTPReqHandler::HandleSocksProxyReply, this, std::placeholders::_1, std::placeholders::_2));
}
void HTTPReqHandler::HandoverToUpstreamProxy()
{
LogPrint(eLogDebug, "HTTPProxy: handover to socks proxy");
LogPrint(eLogDebug, "HTTPProxy: Handover to SOCKS proxy");
auto connection = std::make_shared<i2p::client::TCPIPPipe>(GetOwner(), m_proxysock, m_sock);
m_sock = nullptr;
m_proxysock = nullptr;
@ -576,7 +576,7 @@ namespace proxy {
});
} else {
m_send_buf = m_ClientRequestBuffer.str();
LogPrint(eLogDebug, "HTTPProxy: send ", m_send_buf.size(), " bytes");
LogPrint(eLogDebug, "HTTPProxy: Send ", m_send_buf.size(), " bytes");
boost::asio::async_write(*m_proxysock, boost::asio::buffer(m_send_buf), boost::asio::transfer_all(), [&](const boost::system::error_code & ec, std::size_t transferred)
{
if(ec) GenericProxyError(tr("failed to send request to upstream"), ec.message());
@ -606,7 +606,7 @@ namespace proxy {
void HTTPReqHandler::HandleUpstreamHTTPProxyConnect(const boost::system::error_code & ec)
{
if(!ec) {
LogPrint(eLogDebug, "HTTPProxy: connected to http upstream");
LogPrint(eLogDebug, "HTTPProxy: Connected to http upstream");
GenericProxyError(tr("cannot connect"), tr("http out proxy not implemented"));
} else GenericProxyError(tr("cannot connect to upstream http proxy"), ec.message());
}
@ -614,10 +614,10 @@ namespace proxy {
/* will be called after some data received from client */
void HTTPReqHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len)
{
LogPrint(eLogDebug, "HTTPProxy: sock recv: ", len, " bytes, recv buf: ", m_recv_buf.length(), ", send buf: ", m_send_buf.length());
LogPrint(eLogDebug, "HTTPProxy: Sock recv: ", len, " bytes, recv buf: ", m_recv_buf.length(), ", send buf: ", m_send_buf.length());
if(ecode)
{
LogPrint(eLogWarning, "HTTPProxy: sock recv got error: ", ecode);
LogPrint(eLogWarning, "HTTPProxy: Sock recv got error: ", ecode);
Terminate();
return;
}
@ -640,7 +640,7 @@ namespace proxy {
void HTTPReqHandler::HandleStreamRequestComplete (std::shared_ptr<i2p::stream::Stream> stream)
{
if (!stream) {
LogPrint (eLogError, "HTTPProxy: error when creating the stream, check the previous warnings for more info");
LogPrint (eLogError, "HTTPProxy: Error when creating the stream, check the previous warnings for more info");
GenericProxyError(tr("Host is down"), tr("Can't create connection to requested host, it may be down. Please try again later."));
return;
}

View file

@ -59,7 +59,7 @@ namespace client
if (m_Decryptor)
return m_Decryptor->Decrypt (encrypted, data);
else
LogPrint (eLogError, "I2CP: decryptor is not set");
LogPrint (eLogError, "I2CP: Decryptor is not set");
return false;
}
@ -392,7 +392,7 @@ namespace client
if (m_SessionID != 0xFFFF)
{
m_Owner.RemoveSession (GetSessionID ());
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " terminated");
LogPrint (eLogDebug, "I2CP: Session ", m_SessionID, " terminated");
m_SessionID = 0xFFFF;
}
}
@ -416,7 +416,7 @@ namespace client
m_SendQueue.Add (sendBuf);
else
{
LogPrint (eLogWarning, "I2CP: send queue size exceeds ", I2CP_MAX_SEND_QUEUE_SIZE);
LogPrint (eLogWarning, "I2CP: Send queue size exceeds ", I2CP_MAX_SEND_QUEUE_SIZE);
return;
}
}
@ -524,7 +524,7 @@ namespace client
size_t offset = identity->FromBuffer (buf, len);
if (!offset)
{
LogPrint (eLogError, "I2CP: create session malformed identity");
LogPrint (eLogError, "I2CP: Create session malformed identity");
SendSessionStatusMessage (3); // invalid
return;
}
@ -532,7 +532,7 @@ namespace client
offset += 2;
if (optionsSize > len - offset)
{
LogPrint (eLogError, "I2CP: options size ", optionsSize, "exceeds message size");
LogPrint (eLogError, "I2CP: Options size ", optionsSize, "exceeds message size");
SendSessionStatusMessage (3); // invalid
return;
}
@ -550,18 +550,18 @@ namespace client
std::make_shared<I2CPDestination>(m_Owner.GetService (), shared_from_this (), identity, true, params):
std::make_shared<RunnableI2CPDestination>(shared_from_this (), identity, true, params);
SendSessionStatusMessage (1); // created
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " created");
LogPrint (eLogDebug, "I2CP: Session ", m_SessionID, " created");
m_Destination->Start ();
}
else
{
LogPrint (eLogError, "I2CP: session already exists");
LogPrint (eLogError, "I2CP: Session already exists");
SendSessionStatusMessage (4); // refused
}
}
else
{
LogPrint (eLogError, "I2CP: create session signature verification failed");
LogPrint (eLogError, "I2CP: Create session signature verification failed");
SendSessionStatusMessage (3); // invalid
}
}
@ -569,7 +569,7 @@ namespace client
void I2CPSession::DestroySessionMessageHandler (const uint8_t * buf, size_t len)
{
SendSessionStatusMessage (0); // destroy
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " destroyed");
LogPrint (eLogDebug, "I2CP: Session ", m_SessionID, " destroyed");
Terminate ();
}
@ -604,29 +604,29 @@ namespace client
{
if(m_Destination->Reconfigure(opts))
{
LogPrint(eLogInfo, "I2CP: reconfigured destination");
LogPrint(eLogInfo, "I2CP: Reconfigured destination");
status = 2; // updated
}
else
LogPrint(eLogWarning, "I2CP: failed to reconfigure destination");
LogPrint(eLogWarning, "I2CP: Failed to reconfigure destination");
}
else
LogPrint(eLogError, "I2CP: invalid reconfigure message signature");
LogPrint(eLogError, "I2CP: Invalid reconfigure message signature");
}
else
LogPrint(eLogError, "I2CP: mapping size mismatch");
LogPrint(eLogError, "I2CP: Mapping size mismatch");
}
else
LogPrint(eLogError, "I2CP: destination mismatch");
LogPrint(eLogError, "I2CP: Destination mismatch");
}
else
LogPrint(eLogError, "I2CP: malfromed destination");
LogPrint(eLogError, "I2CP: Malfromed destination");
}
else
LogPrint(eLogError, "I2CP: session mismatch");
LogPrint(eLogError, "I2CP: Session mismatch");
}
else
LogPrint(eLogError, "I2CP: short message");
LogPrint(eLogError, "I2CP: Short message");
SendSessionStatusMessage (status);
}
@ -668,7 +668,7 @@ namespace client
}
}
else
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
LogPrint (eLogError, "I2CP: Unexpected sessionID ", sessionID);
}
void I2CPSession::CreateLeaseSet2MessageHandler (const uint8_t * buf, size_t len)
@ -683,7 +683,7 @@ namespace client
i2p::data::LeaseSet2 ls (storeType, buf + offset, len - offset); // outer layer only for encrypted
if (!ls.IsValid ())
{
LogPrint (eLogError, "I2CP: invalid LeaseSet2 of type ", storeType);
LogPrint (eLogError, "I2CP: Invalid LeaseSet2 of type ", storeType);
return;
}
offset += ls.GetBufferLen ();
@ -709,7 +709,7 @@ namespace client
}
}
else
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
LogPrint (eLogError, "I2CP: Unexpected sessionID ", sessionID);
}
void I2CPSession::SendMessageMessageHandler (const uint8_t * buf, size_t len)
@ -735,14 +735,14 @@ namespace client
m_Destination->SendMsgTo (buf + offset, payloadLen, identity.GetIdentHash (), nonce);
}
else
LogPrint(eLogError, "I2CP: cannot send message, too big");
LogPrint(eLogError, "I2CP: Cannot send message, too big");
}
else
LogPrint(eLogError, "I2CP: invalid identity");
LogPrint(eLogError, "I2CP: Invalid identity");
}
}
else
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
LogPrint (eLogError, "I2CP: Unexpected sessionID ", sessionID);
}
void I2CPSession::SendMessageExpiresMessageHandler (const uint8_t * buf, size_t len)
@ -770,7 +770,7 @@ namespace client
if (!addr || !addr->IsIdentHash ())
{
// TODO: handle blinded addresses
LogPrint (eLogError, "I2CP: address ", name, " not found");
LogPrint (eLogError, "I2CP: Address ", name, " not found");
SendHostReplyMessage (requestID, nullptr);
return;
}
@ -779,7 +779,7 @@ namespace client
break;
}
default:
LogPrint (eLogError, "I2CP: request type ", (int)buf[10], " is not supported");
LogPrint (eLogError, "I2CP: Request type ", (int)buf[10], " is not supported");
SendHostReplyMessage (requestID, nullptr);
return;
}
@ -805,7 +805,7 @@ namespace client
SendHostReplyMessage (requestID, nullptr);
}
else
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
LogPrint (eLogError, "I2CP: Unexpected sessionID ", sessionID);
}
void I2CPSession::SendHostReplyMessage (uint32_t requestID, std::shared_ptr<const i2p::data::IdentityEx> identity)
@ -900,7 +900,7 @@ namespace client
m_SendQueue.Add (sendBuf);
else
{
LogPrint (eLogWarning, "I2CP: send queue size exceeds ", I2CP_MAX_SEND_QUEUE_SIZE);
LogPrint (eLogWarning, "I2CP: Send queue size exceeds ", I2CP_MAX_SEND_QUEUE_SIZE);
return;
}
}
@ -980,15 +980,15 @@ namespace client
auto ep = socket->remote_endpoint (ec);
if (!ec)
{
LogPrint (eLogDebug, "I2CP: new connection from ", ep);
LogPrint (eLogDebug, "I2CP: New connection from ", ep);
auto session = std::make_shared<I2CPSession>(*this, socket);
session->Start ();
}
else
LogPrint (eLogError, "I2CP: incoming connection error ", ec.message ());
LogPrint (eLogError, "I2CP: Incoming connection error ", ec.message ());
}
else
LogPrint (eLogError, "I2CP: accept error: ", ecode.message ());
LogPrint (eLogError, "I2CP: Accept error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Accept ();
@ -999,7 +999,7 @@ namespace client
if (!session) return false;
if (!m_Sessions.insert({session->GetSessionID (), session}).second)
{
LogPrint (eLogError, "I2CP: duplicate session id ", session->GetSessionID ());
LogPrint (eLogError, "I2CP: Duplicate session id ", session->GetSessionID ());
return false;
}
return true;

View file

@ -193,7 +193,7 @@ namespace client
std::placeholders::_1, std::placeholders::_2));
}
else
LogPrint(eLogError, "TCPIPPipe: upstream receive: no socket");
LogPrint(eLogError, "TCPIPPipe: Upstream receive: No socket");
}
void TCPIPPipe::AsyncReceiveDownstream()
@ -204,14 +204,14 @@ namespace client
std::placeholders::_1, std::placeholders::_2));
}
else
LogPrint(eLogError, "TCPIPPipe: downstream receive: no socket");
LogPrint(eLogError, "TCPIPPipe: Downstream receive: No socket");
}
void TCPIPPipe::UpstreamWrite(size_t len)
{
if (m_up)
{
LogPrint(eLogDebug, "TCPIPPipe: upstream: ", (int) len, " bytes written");
LogPrint(eLogDebug, "TCPIPPipe: Upstream: ", (int) len, " bytes written");
boost::asio::async_write(*m_up, boost::asio::buffer(m_upstream_buf, len),
boost::asio::transfer_all(),
std::bind(&TCPIPPipe::HandleUpstreamWrite,
@ -219,14 +219,14 @@ namespace client
std::placeholders::_1));
}
else
LogPrint(eLogError, "TCPIPPipe: upstream write: no socket");
LogPrint(eLogError, "TCPIPPipe: Upstream write: no socket");
}
void TCPIPPipe::DownstreamWrite(size_t len)
{
if (m_down)
{
LogPrint(eLogDebug, "TCPIPPipe: downstream: ", (int) len, " bytes written");
LogPrint(eLogDebug, "TCPIPPipe: Downstream: ", (int) len, " bytes written");
boost::asio::async_write(*m_down, boost::asio::buffer(m_downstream_buf, len),
boost::asio::transfer_all(),
std::bind(&TCPIPPipe::HandleDownstreamWrite,
@ -234,16 +234,16 @@ namespace client
std::placeholders::_1));
}
else
LogPrint(eLogError, "TCPIPPipe: downstream write: no socket");
LogPrint(eLogError, "TCPIPPipe: Downstream write: No socket");
}
void TCPIPPipe::HandleDownstreamReceived(const boost::system::error_code & ecode, std::size_t bytes_transfered)
{
LogPrint(eLogDebug, "TCPIPPipe: downstream: ", (int) bytes_transfered, " bytes received");
LogPrint(eLogDebug, "TCPIPPipe: Downstream: ", (int) bytes_transfered, " bytes received");
if (ecode)
{
LogPrint(eLogError, "TCPIPPipe: downstream read error:" , ecode.message());
LogPrint(eLogError, "TCPIPPipe: Downstream read error:" , ecode.message());
if (ecode != boost::asio::error::operation_aborted)
Terminate();
} else {
@ -256,7 +256,7 @@ namespace client
void TCPIPPipe::HandleDownstreamWrite(const boost::system::error_code & ecode) {
if (ecode)
{
LogPrint(eLogError, "TCPIPPipe: downstream write error:" , ecode.message());
LogPrint(eLogError, "TCPIPPipe: Downstream write error:" , ecode.message());
if (ecode != boost::asio::error::operation_aborted)
Terminate();
}
@ -267,7 +267,7 @@ namespace client
void TCPIPPipe::HandleUpstreamWrite(const boost::system::error_code & ecode) {
if (ecode)
{
LogPrint(eLogError, "TCPIPPipe: upstream write error:" , ecode.message());
LogPrint(eLogError, "TCPIPPipe: Upstream write error:" , ecode.message());
if (ecode != boost::asio::error::operation_aborted)
Terminate();
}
@ -277,10 +277,10 @@ namespace client
void TCPIPPipe::HandleUpstreamReceived(const boost::system::error_code & ecode, std::size_t bytes_transfered)
{
LogPrint(eLogDebug, "TCPIPPipe: upstream ", (int)bytes_transfered, " bytes received");
LogPrint(eLogDebug, "TCPIPPipe: Upstream ", (int)bytes_transfered, " bytes received");
if (ecode)
{
LogPrint(eLogError, "TCPIPPipe: upstream read error:" , ecode.message());
LogPrint(eLogError, "TCPIPPipe: Upstream read error:" , ecode.message());
if (ecode != boost::asio::error::operation_aborted)
Terminate();
} else {

View file

@ -87,7 +87,7 @@ namespace client
boost::system::error_code ec;
sock->bind (boost::asio::ip::tcp::endpoint (ourIP, 0), ec);
if (ec)
LogPrint (eLogError, "I2PTunnel: can't bind ourIP to ", ourIP.to_string (), ": ", ec.message ());
LogPrint (eLogError, "I2PTunnel: Can't bind ourIP to ", ourIP.to_string (), ": ", ec.message ());
}
#endif
@ -122,7 +122,7 @@ namespace client
boost::system::error_code ec;
m_Socket->bind (boost::asio::ip::tcp::endpoint (localAddress, 0), ec);
if (ec)
LogPrint (eLogError, "I2PTunnel: can't bind to ", localAddress.to_string (), ": ", ec.message ());
LogPrint (eLogError, "I2PTunnel: Can't bind to ", localAddress.to_string (), ": ", ec.message ());
}
Connect (false);
}
@ -155,7 +155,7 @@ namespace client
{
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogError, "I2PTunnel: read error: ", ecode.message ());
LogPrint (eLogError, "I2PTunnel: Read error: ", ecode.message ());
Terminate ();
}
}
@ -183,7 +183,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "I2PTunnel: write error: ", ecode.message ());
LogPrint (eLogError, "I2PTunnel: Write error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ();
}
@ -221,7 +221,7 @@ namespace client
{
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogError, "I2PTunnel: stream read error: ", ecode.message ());
LogPrint (eLogError, "I2PTunnel: Stream read error: ", ecode.message ());
if (bytes_transferred > 0)
Write (m_StreamBuffer, bytes_transferred); // postpone termination
else if (ecode == boost::asio::error::timed_out && m_Stream && m_Stream->IsOpen ())
@ -246,12 +246,12 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "I2PTunnel: connect error: ", ecode.message ());
LogPrint (eLogError, "I2PTunnel: Connect error: ", ecode.message ());
Terminate ();
}
else
{
LogPrint (eLogDebug, "I2PTunnel: connected");
LogPrint (eLogDebug, "I2PTunnel: Connected");
if (m_IsQuiet)
StreamReceive ();
else
@ -505,7 +505,7 @@ namespace client
if (stream)
{
if (Kill()) return;
LogPrint (eLogDebug, "I2PTunnel: new connection");
LogPrint (eLogDebug, "I2PTunnel: New connection");
auto connection = std::make_shared<I2PTunnelConnection>(GetOwner(), m_Socket, stream);
GetOwner()->AddHandler (connection);
connection->I2PConnect ();
@ -681,7 +681,7 @@ namespace client
}
auto addr = ep.address ();
LogPrint (eLogInfo, "I2PTunnel: server tunnel ", (*it).host_name (), " has been resolved to ", addr);
LogPrint (eLogInfo, "I2PTunnel: Server tunnel ", (*it).host_name (), " has been resolved to ", addr);
m_Endpoint.address (addr);
Accept ();
}
@ -702,7 +702,7 @@ namespace client
if (!ec)
m_LocalAddress.reset (new boost::asio::ip::address (addr));
else
LogPrint (eLogError, "I2PTunnel: can't set local address ", localAddress);
LogPrint (eLogError, "I2PTunnel: Can't set local address ", localAddress);
}
void I2PServerTunnel::Accept ()
@ -829,7 +829,7 @@ namespace client
if (s->Identity.GetLL()[0] == ih.GetLL()[0] && remotePort == s->RemotePort)
{
/** found existing session */
LogPrint(eLogDebug, "UDPServer: found session ", s->IPSocket.local_endpoint(), " ", ih.ToBase32());
LogPrint(eLogDebug, "UDPServer: Found session ", s->IPSocket.local_endpoint(), " ", ih.ToBase32());
return s;
}
}
@ -874,7 +874,7 @@ namespace client
{
if(!ecode)
{
LogPrint(eLogDebug, "UDPSession: forward ", len, "B from ", FromEndpoint);
LogPrint(eLogDebug, "UDPSession: Forward ", len, "B from ", FromEndpoint);
auto ts = i2p::util::GetMillisecondsSinceEpoch();
auto session = m_Destination->GetSession (Identity);
if (ts > LastActivity + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
@ -892,7 +892,7 @@ namespace client
numPackets++;
}
if (numPackets > 0)
LogPrint(eLogDebug, "UDPSession: forward more ", numPackets, "packets B from ", FromEndpoint);
LogPrint(eLogDebug, "UDPSession: Forward more ", numPackets, "packets B from ", FromEndpoint);
m_Destination->FlushSendQueue (session);
LastActivity = ts;
Receive();
@ -920,7 +920,7 @@ namespace client
auto dgram = m_LocalDest->GetDatagramDestination();
if (dgram) dgram->ResetReceiver();
LogPrint(eLogInfo, "UDPServer: done");
LogPrint(eLogInfo, "UDPServer: Done");
}
void I2PUDPServerTunnel::Start()
@ -997,7 +997,7 @@ namespace client
return;
}
if(!m_RemoteIdent) {
LogPrint(eLogWarning, "UDP Client: remote endpoint not resolved yet");
LogPrint(eLogWarning, "UDP Client: Remote endpoint not resolved yet");
RecvFromLocal();
return; // drop, remote not resolved
}
@ -1016,7 +1016,7 @@ namespace client
}
// send off to remote i2p destination
auto ts = i2p::util::GetMillisecondsSinceEpoch();
LogPrint(eLogDebug, "UDP Client: send ", transferred, " to ", m_RemoteIdent->ToBase32(), ":", RemotePort);
LogPrint(eLogDebug, "UDP Client: Send ", transferred, " to ", m_RemoteIdent->ToBase32(), ":", RemotePort);
auto session = m_LocalDest->GetDatagramDestination()->GetSession (*m_RemoteIdent);
if (ts > m_LastSession->second + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
m_LocalDest->GetDatagramDestination()->SendDatagram (session, m_RecvBuff, transferred, remotePort, RemotePort);
@ -1035,7 +1035,7 @@ namespace client
numPackets++;
}
if (numPackets)
LogPrint(eLogDebug, "UDP Client: sent ", numPackets, " more packets to ", m_RemoteIdent->ToBase32());
LogPrint(eLogDebug, "UDP Client: Sent ", numPackets, " more packets to ", m_RemoteIdent->ToBase32());
m_LocalDest->GetDatagramDestination()->FlushSendQueue (session);
// mark convo as active
@ -1058,12 +1058,12 @@ namespace client
std::shared_ptr<const Address> addr;
while(!(addr = context.GetAddressBook().GetAddress(m_RemoteDest)) && !m_cancel_resolve)
{
LogPrint(eLogWarning, "UDP Tunnel: failed to lookup ", m_RemoteDest);
LogPrint(eLogWarning, "UDP Tunnel: Failed to lookup ", m_RemoteDest);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
if(m_cancel_resolve)
{
LogPrint(eLogError, "UDP Tunnel: lookup of ", m_RemoteDest, " was cancelled");
LogPrint(eLogError, "UDP Tunnel: Lookup of ", m_RemoteDest, " was cancelled");
return;
}
if (!addr || !addr->IsIdentHash ())
@ -1073,7 +1073,7 @@ namespace client
}
m_RemoteIdent = new i2p::data::IdentHash;
*m_RemoteIdent = addr->identHash;
LogPrint(eLogInfo, "UDP Tunnel: resolved ", m_RemoteDest, " to ", m_RemoteIdent->ToBase32());
LogPrint(eLogInfo, "UDP Tunnel: Resolved ", m_RemoteDest, " to ", m_RemoteIdent->ToBase32());
}
void I2PUDPClientTunnel::HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
@ -1081,7 +1081,7 @@ namespace client
if(m_RemoteIdent && from.GetIdentHash() == *m_RemoteIdent)
HandleRecvFromI2PRaw (fromPort, toPort, buf, len);
else
LogPrint(eLogWarning, "UDP Client: unwarranted traffic from ", from.GetIdentHash().ToBase32());
LogPrint(eLogWarning, "UDP Client: Unwarranted traffic from ", from.GetIdentHash().ToBase32());
}
void I2PUDPClientTunnel::HandleRecvFromI2PRaw(uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
@ -1093,14 +1093,14 @@ namespace client
// found convo
if (len > 0)
{
LogPrint(eLogDebug, "UDP Client: got ", len, "B from ", m_RemoteIdent ? m_RemoteIdent->ToBase32() : "");
LogPrint(eLogDebug, "UDP Client: Got ", len, "B from ", m_RemoteIdent ? m_RemoteIdent->ToBase32() : "");
m_LocalSocket.send_to(boost::asio::buffer(buf, len), itr->second->first);
// mark convo as active
itr->second->second = i2p::util::GetMillisecondsSinceEpoch();
}
}
else
LogPrint(eLogWarning, "UDP Client: not tracking udp session using port ", (int) toPort);
LogPrint(eLogWarning, "UDP Client: Not tracking udp session using port ", (int) toPort);
}
I2PUDPClientTunnel::~I2PUDPClientTunnel()

View file

@ -33,14 +33,14 @@ namespace client
RequestDestination(m_RemoteIdent, std::bind(&MatchedTunnelDestination::HandleFoundCurrentLeaseSet, this, std::placeholders::_1));
}
else
LogPrint(eLogWarning, "Destination: failed to resolve ", m_RemoteName);
LogPrint(eLogWarning, "Destination: Failed to resolve ", m_RemoteName);
}
void MatchedTunnelDestination::HandleFoundCurrentLeaseSet(std::shared_ptr<const i2p::data::LeaseSet> ls)
{
if(ls)
{
LogPrint(eLogDebug, "Destination: resolved remote lease set for ", m_RemoteName);
LogPrint(eLogDebug, "Destination: Resolved remote lease set for ", m_RemoteName);
m_RemoteLeaseSet = ls;
}
else
@ -96,9 +96,9 @@ namespace client
if(obep)
{
path.Add (obep);
LogPrint(eLogDebug, "Destination: found OBEP matching IBGW");
LogPrint(eLogDebug, "Destination: Found OBEP matching IBGW");
} else
LogPrint(eLogWarning, "Destination: could not find proper IBGW for matched outbound tunnel");
LogPrint(eLogWarning, "Destination: Could not find proper IBGW for matched outbound tunnel");
}
}
return true;

View file

@ -101,7 +101,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: handshake read error: ", ecode.message ());
LogPrint (eLogError, "SAM: Handshake read error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("SAM: handshake read error");
}
@ -111,7 +111,7 @@ namespace client
char * eol = (char *)memchr (m_Buffer, '\n', bytes_transferred);
if (eol)
*eol = 0;
LogPrint (eLogDebug, "SAM: handshake ", m_Buffer);
LogPrint (eLogDebug, "SAM: Handshake ", m_Buffer);
char * separator = strchr (m_Buffer, ' ');
if (separator)
{
@ -168,7 +168,7 @@ namespace client
}
else
{
LogPrint (eLogError, "SAM: handshake mismatch");
LogPrint (eLogError, "SAM: Handshake mismatch");
Terminate ("SAM: handshake mismatch");
}
}
@ -183,7 +183,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: handshake reply send error: ", ecode.message ());
LogPrint (eLogError, "SAM: Handshake reply send error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("SAM: handshake reply send error");
}
@ -216,7 +216,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: reply send error: ", ecode.message ());
LogPrint (eLogError, "SAM: Reply send error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("SAM: reply send error");
}
@ -233,7 +233,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: read error: ", ecode.message ());
LogPrint (eLogError, "SAM: Read error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("SAM: read error");
}
@ -295,20 +295,20 @@ namespace client
}
else
{
LogPrint (eLogError, "SAM: unexpected message ", m_Buffer);
LogPrint (eLogError, "SAM: Unexpected message ", m_Buffer);
Terminate ("SAM: unexpected message");
}
}
else
{
LogPrint (eLogError, "SAM: malformed message ", m_Buffer);
LogPrint (eLogError, "SAM: Malformed message ", m_Buffer);
Terminate ("malformed message");
}
}
else
{
LogPrint (eLogWarning, "SAM: incomplete message ", bytes_transferred);
LogPrint (eLogWarning, "SAM: Incomplete message ", bytes_transferred);
m_BufferOffset = bytes_transferred;
// try to receive remaining message
Receive ();
@ -331,7 +331,7 @@ namespace client
void SAMSocket::ProcessSessionCreate (char * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: session create: ", buf);
LogPrint (eLogDebug, "SAM: Session create: ", buf);
std::map<std::string, std::string> params;
ExtractParams (buf, params);
std::string& style = params[SAM_PARAM_STYLE];
@ -476,7 +476,7 @@ namespace client
void SAMSocket::ProcessStreamConnect (char * buf, size_t len, size_t rem)
{
LogPrint (eLogDebug, "SAM: stream connect: ", buf);
LogPrint (eLogDebug, "SAM: Stream connect: ", buf);
if ( m_SocketType != eSAMSocketTypeUnknown)
{
SendI2PError ("Socket already in use");
@ -567,14 +567,14 @@ namespace client
Connect (leaseSet);
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);
}
}
void SAMSocket::ProcessStreamAccept (char * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: stream accept: ", buf);
LogPrint (eLogDebug, "SAM: Stream accept: ", buf);
if ( m_SocketType != eSAMSocketTypeUnknown)
{
SendI2PError ("Socket already in use");
@ -603,7 +603,7 @@ namespace client
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;
ExtractParams (buf, params);
std::string& id = params[SAM_PARAM_ID];
@ -650,7 +650,7 @@ namespace client
size_t SAMSocket::ProcessDatagramSend (char * buf, size_t len, const char * data)
{
LogPrint (eLogDebug, "SAM: datagram send: ", buf, " ", len);
LogPrint (eLogDebug, "SAM: Datagram send: ", buf, " ", len);
std::map<std::string, std::string> params;
ExtractParams (buf, params);
size_t size = std::stoi(params[SAM_PARAM_SIZE]), offset = data - buf;
@ -670,14 +670,14 @@ namespace client
d->SendRawDatagramTo ((const uint8_t *)data, size, dest.GetIdentHash ());
}
else
LogPrint (eLogError, "SAM: missing datagram destination");
LogPrint (eLogError, "SAM: Missing datagram destination");
}
else
LogPrint (eLogError, "SAM: session is not created from DATAGRAM SEND");
LogPrint (eLogError, "SAM: Session is not created from DATAGRAM SEND");
}
else
{
LogPrint (eLogWarning, "SAM: sent datagram size ", size, " exceeds buffer ", len - offset);
LogPrint (eLogWarning, "SAM: Sent datagram size ", size, " exceeds buffer ", len - offset);
return 0; // try to receive more
}
return offset + size;
@ -685,7 +685,7 @@ namespace client
void SAMSocket::ProcessDestGenerate (char * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: dest generate");
LogPrint (eLogDebug, "SAM: Dest generate");
std::map<std::string, std::string> params;
ExtractParams (buf, params);
// extract signature type
@ -722,7 +722,7 @@ namespace client
void SAMSocket::ProcessNamingLookup (char * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: naming lookup: ", buf);
LogPrint (eLogDebug, "SAM: Naming lookup: ", buf);
std::map<std::string, std::string> params;
ExtractParams (buf, params);
std::string& name = params[SAM_PARAM_NAME];
@ -753,7 +753,7 @@ namespace client
}
else
{
LogPrint (eLogError, "SAM: naming failed, unknown address ", name);
LogPrint (eLogError, "SAM: Naming failed, unknown address ", name);
#ifdef _MSC_VER
size_t len = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, name.c_str());
#else
@ -768,7 +768,7 @@ namespace client
auto session = m_Owner.FindSession(m_ID);
if (session && session->Type == eSAMSessionTypeMaster)
{
LogPrint (eLogDebug, "SAM: subsession add: ", buf);
LogPrint (eLogDebug, "SAM: Subsession add: ", buf);
auto masterSession = std::static_pointer_cast<SAMMasterSession>(session);
std::map<std::string, std::string> params;
ExtractParams (buf, params);
@ -813,7 +813,7 @@ namespace client
auto session = m_Owner.FindSession(m_ID);
if (session && session->Type == eSAMSessionTypeMaster)
{
LogPrint (eLogDebug, "SAM: subsession remove: ", buf);
LogPrint (eLogDebug, "SAM: Subsession remove: ", buf);
auto masterSession = std::static_pointer_cast<SAMMasterSession>(session);
std::map<std::string, std::string> params;
ExtractParams (buf, params);
@ -832,7 +832,7 @@ namespace client
void SAMSocket::SendI2PError(const std::string & msg)
{
LogPrint (eLogError, "SAM: i2p error ", msg);
LogPrint (eLogError, "SAM: I2P error: ", msg);
#ifdef _MSC_VER
size_t len = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_SESSION_STATUS_I2P_ERROR, msg.c_str());
#else
@ -850,7 +850,7 @@ namespace client
}
else
{
LogPrint (eLogError, "SAM: naming lookup failed. LeaseSet for ", name, " not found");
LogPrint (eLogError, "SAM: Naming lookup failed. LeaseSet for ", name, " not found");
#ifdef _MSC_VER
size_t len = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, name.c_str());
#else
@ -901,7 +901,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: read error: ", ecode.message ());
LogPrint (eLogError, "SAM: Read error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("read error");
}
@ -978,7 +978,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: stream read error: ", ecode.message ());
LogPrint (eLogError, "SAM: Stream read error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
{
if (bytes_transferred > 0)
@ -1015,7 +1015,7 @@ namespace client
{
if (ecode)
{
LogPrint (eLogError, "SAM: socket write error: ", ecode.message ());
LogPrint (eLogError, "SAM: Socket write error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Terminate ("socket write error at HandleWriteI2PData");
}
@ -1029,7 +1029,7 @@ namespace client
{
if (stream)
{
LogPrint (eLogDebug, "SAM: incoming I2P connection for session ", m_ID);
LogPrint (eLogDebug, "SAM: Incoming I2P connection for session ", m_ID);
m_SocketType = eSAMSocketTypeStream;
m_IsAccepting = false;
m_Stream = stream;
@ -1072,7 +1072,7 @@ namespace client
{
if (stream)
{
LogPrint (eLogDebug, "SAM: incoming forward I2P connection for session ", m_ID);
LogPrint (eLogDebug, "SAM: Incoming forward I2P connection for session ", m_ID);
auto newSocket = std::make_shared<SAMSocket>(m_Owner);
newSocket->SetSocketType (eSAMSocketTypeStream);
auto s = shared_from_this ();
@ -1106,7 +1106,7 @@ namespace client
void SAMSocket::HandleI2PDatagramReceive (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: datagram received ", len);
LogPrint (eLogDebug, "SAM: Datagram received ", len);
auto base64 = from.ToBase64 ();
auto session = m_Owner.FindSession(m_ID);
if(session)
@ -1142,14 +1142,14 @@ namespace client
WriteI2PData(len + l);
}
else
LogPrint (eLogWarning, "SAM: received datagram size ", len," exceeds buffer");
LogPrint (eLogWarning, "SAM: Received datagram size ", len," exceeds buffer");
}
}
}
void SAMSocket::HandleI2PRawDatagramReceive (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
{
LogPrint (eLogDebug, "SAM: raw datagram received ", len);
LogPrint (eLogDebug, "SAM: Raw datagram received ", len);
auto session = m_Owner.FindSession(m_ID);
if(session)
{
@ -1170,7 +1170,7 @@ namespace client
WriteI2PData(len + l);
}
else
LogPrint (eLogWarning, "SAM: received raw datagram size ", len," exceeds buffer");
LogPrint (eLogWarning, "SAM: Received raw datagram size ", len," exceeds buffer");
}
}
}
@ -1288,7 +1288,7 @@ namespace client
}
catch (const std::exception& ex)
{
LogPrint (eLogError, "SAM: runtime exception: ", ex.what ());
LogPrint (eLogError, "SAM: Runtime exception: ", ex.what ());
}
{
@ -1327,15 +1327,15 @@ namespace client
auto ep = socket->GetSocket ().remote_endpoint (ec);
if (!ec)
{
LogPrint (eLogDebug, "SAM: new connection from ", ep);
LogPrint (eLogDebug, "SAM: New connection from ", ep);
AddSocket (socket);
socket->ReceiveHandshake ();
}
else
LogPrint (eLogError, "SAM: incoming connection error ", ec.message ());
LogPrint (eLogError, "SAM: Incoming connection error: ", ec.message ());
}
else
LogPrint (eLogError, "SAM: accept error: ", ecode.message ());
LogPrint (eLogError, "SAM: Accept error: ", ecode.message ());
if (ecode != boost::asio::error::operation_aborted)
Accept ();
@ -1479,7 +1479,7 @@ namespace client
{
*eol = 0; eol++;
size_t payloadLen = bytes_transferred - ((uint8_t *)eol - m_DatagramReceiveBuffer);
LogPrint (eLogDebug, "SAM: datagram received ", m_DatagramReceiveBuffer," size=", payloadLen);
LogPrint (eLogDebug, "SAM: Datagram received ", m_DatagramReceiveBuffer," size=", payloadLen);
char * sessionID = strchr ((char *)m_DatagramReceiveBuffer, ' ');
if (sessionID)
{
@ -1510,11 +1510,11 @@ namespace client
LogPrint (eLogError, "SAM: Missing sessionID");
}
else
LogPrint(eLogError, "SAM: invalid datagram");
LogPrint(eLogError, "SAM: Invalid datagram");
ReceiveDatagram ();
}
else
LogPrint (eLogError, "SAM: datagram receive error: ", ecode.message ());
LogPrint (eLogError, "SAM: Datagram receive error: ", ecode.message ());
}
bool SAMBridge::ResolveSignatureType (const std::string& name, i2p::data::SigningKeyType& type) const

View file

@ -191,13 +191,13 @@ namespace proxy
void SOCKSHandler::AsyncSockRead()
{
LogPrint(eLogDebug, "SOCKS: async sock read");
LogPrint(eLogDebug, "SOCKS: Async sock read");
if (m_sock) {
m_sock->async_receive(boost::asio::buffer(m_sock_buff, socks_buffer_size),
std::bind(&SOCKSHandler::HandleSockRecv, shared_from_this(),
std::placeholders::_1, std::placeholders::_2));
} else {
LogPrint(eLogError,"SOCKS: no socket for read");
LogPrint(eLogError,"SOCKS: No socket for read");
}
}
@ -206,19 +206,19 @@ namespace proxy
if (Kill()) return;
if (m_sock)
{
LogPrint(eLogDebug, "SOCKS: closing socket");
LogPrint(eLogDebug, "SOCKS: Closing socket");
m_sock->close();
m_sock = nullptr;
}
if (m_upstreamSock)
{
LogPrint(eLogDebug, "SOCKS: closing upstream socket");
LogPrint(eLogDebug, "SOCKS: Closing upstream socket");
m_upstreamSock->close();
m_upstreamSock = nullptr;
}
if (m_stream)
{
LogPrint(eLogDebug, "SOCKS: closing stream");
LogPrint(eLogDebug, "SOCKS: Closing stream");
m_stream.reset ();
}
Done(shared_from_this());
@ -386,7 +386,7 @@ namespace proxy
if ( m_cmd != CMD_CONNECT )
{
// TODO: we need to support binds and other shit!
LogPrint(eLogError, "SOCKS: unsupported command: ", m_cmd);
LogPrint(eLogError, "SOCKS: Unsupported command: ", m_cmd);
SocksRequestFailed(SOCKS5_CMD_UNSUP);
return false;
}
@ -399,7 +399,7 @@ namespace proxy
LogPrint(eLogError, "SOCKS: v5 unsupported address type: ", m_addrtype);
break;
case SOCKS4:
LogPrint(eLogError, "SOCKS: request with v4a rejected because it's actually SOCKS4");
LogPrint(eLogError, "SOCKS: Request with v4a rejected because it's actually SOCKS4");
break;
}
SocksRequestFailed(SOCKS5_ADDR_UNSUP);
@ -426,7 +426,7 @@ namespace proxy
EnterState(GET5_AUTHNUM); //Initialize the parser at the right position
break;
default:
LogPrint(eLogError, "SOCKS: rejected invalid version: ", ((int)*sock_buff));
LogPrint(eLogError, "SOCKS: Rejected invalid version: ", ((int)*sock_buff));
Terminate();
return false;
}
@ -456,7 +456,7 @@ namespace proxy
[[fallthrough]];
#endif
default:
LogPrint(eLogError, "SOCKS: invalid command: ", ((int)*sock_buff));
LogPrint(eLogError, "SOCKS: Invalid command: ", ((int)*sock_buff));
SocksRequestFailed(SOCKS5_GEN_FAIL);
return false;
}
@ -558,7 +558,7 @@ namespace proxy
if (m_parseleft == 0) EnterState(GET_PORT);
break;
default:
LogPrint(eLogError, "SOCKS: parse state?? ", m_state);
LogPrint(eLogError, "SOCKS: Parse state?? ", m_state);
Terminate();
return false;
}
@ -576,10 +576,10 @@ namespace proxy
void SOCKSHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len)
{
LogPrint(eLogDebug, "SOCKS: received ", len, " bytes");
LogPrint(eLogDebug, "SOCKS: Received ", len, " bytes");
if(ecode)
{
LogPrint(eLogWarning, "SOCKS: recv got error: ", ecode);
LogPrint(eLogWarning, "SOCKS: Recv got error: ", ecode);
Terminate();
return;
}
@ -589,7 +589,7 @@ namespace proxy
if (m_state == READY)
{
const std::string addr = m_address.dns.ToString();
LogPrint(eLogInfo, "SOCKS: requested ", addr, ":" , m_port);
LogPrint(eLogInfo, "SOCKS: Requested ", addr, ":" , m_port);
const size_t addrlen = addr.size();
// does it end with .i2p?
if ( addr.rfind(".i2p") == addrlen - 4) {
@ -612,7 +612,7 @@ namespace proxy
void SOCKSHandler::SentSocksFailed(const boost::system::error_code & ecode)
{
if (ecode)
LogPrint (eLogError, "SOCKS: closing socket after sending failure because: ", ecode.message ());
LogPrint (eLogError, "SOCKS: Closing socket after sending failure because: ", ecode.message ());
Terminate();
}
@ -621,7 +621,7 @@ namespace proxy
if (!ecode)
{
if (Kill()) return;
LogPrint (eLogInfo, "SOCKS: new I2PTunnel connection");
LogPrint (eLogInfo, "SOCKS: New I2PTunnel connection");
auto connection = std::make_shared<i2p::client::I2PTunnelConnection>(GetOwner(), m_sock, m_stream);
GetOwner()->AddHandler (connection);
connection->I2PConnect (m_remaining_data,m_remaining_data_len);
@ -629,7 +629,7 @@ namespace proxy
}
else
{
LogPrint (eLogError, "SOCKS: closing socket after completion reply because: ", ecode.message ());
LogPrint (eLogError, "SOCKS: Closing socket after completion reply because: ", ecode.message ());
Terminate();
}
}
@ -638,7 +638,7 @@ namespace proxy
{
if (ecode)
{
LogPrint (eLogError, "SOCKS: closing socket after sending reply because: ", ecode.message ());
LogPrint (eLogError, "SOCKS: Closing socket after sending reply because: ", ecode.message ());
Terminate();
}
}
@ -652,14 +652,14 @@ namespace proxy
}
else
{
LogPrint (eLogError, "SOCKS: error when creating the stream, check the previous warnings for more info");
LogPrint (eLogError, "SOCKS: Error when creating the stream, check the previous warnings for more info");
SocksRequestFailed(SOCKS5_HOST_UNREACH);
}
}
void SOCKSHandler::ForwardSOCKS()
{
LogPrint(eLogInfo, "SOCKS: forwarding to upstream");
LogPrint(eLogInfo, "SOCKS: Forwarding to upstream");
EnterState(UPSTREAM_RESOLVE);
boost::asio::ip::tcp::resolver::query q(m_UpstreamProxyAddress, std::to_string(m_UpstreamProxyPort));
m_proxy_resolver.async_resolve(q, std::bind(&SOCKSHandler::HandleUpstreamResolved, shared_from_this(),
@ -668,12 +668,12 @@ namespace proxy
void SOCKSHandler::AsyncUpstreamSockRead()
{
LogPrint(eLogDebug, "SOCKS: async upstream sock read");
LogPrint(eLogDebug, "SOCKS: Async upstream sock read");
if (m_upstreamSock) {
m_upstreamSock->async_read_some(boost::asio::buffer(m_upstream_response, SOCKS_UPSTREAM_SOCKS4A_REPLY_SIZE),
std::bind(&SOCKSHandler::HandleUpstreamSockRecv, shared_from_this(), std::placeholders::_1, std::placeholders::_2));
} else {
LogPrint(eLogError, "SOCKS: no upstream socket for read");
LogPrint(eLogError, "SOCKS: No upstream socket for read");
SocksRequestFailed(SOCKS5_GEN_FAIL);
}
}
@ -685,7 +685,7 @@ namespace proxy
// we are trying to handshake but it failed
SocksRequestFailed(SOCKS5_NET_UNREACH);
} else {
LogPrint(eLogError, "SOCKS: bad state when reading from upstream: ", (int) m_state);
LogPrint(eLogError, "SOCKS: Bad state when reading from upstream: ", (int) m_state);
}
return;
}
@ -694,7 +694,7 @@ namespace proxy
void SOCKSHandler::SocksUpstreamSuccess()
{
LogPrint(eLogInfo, "SOCKS: upstream success");
LogPrint(eLogInfo, "SOCKS: Upstream success");
boost::asio::const_buffers_1 response(nullptr, 0);
switch (m_socksv)
{
@ -734,7 +734,7 @@ namespace proxy
SocksUpstreamSuccess();
} else {
// upstream failure
LogPrint(eLogError, "SOCKS: upstream proxy failure: ", (int) resp);
LogPrint(eLogError, "SOCKS: Upstream proxy failure: ", (int) resp);
// TODO: runtime error?
SocksRequestFailed(SOCKS5_GEN_FAIL);
}
@ -744,30 +744,30 @@ namespace proxy
}
} else {
// invalid state
LogPrint(eLogError, "SOCKS: invalid state reading from upstream: ", (int) m_state);
LogPrint(eLogError, "SOCKS: Invalid state reading from upstream: ", (int) m_state);
}
}
void SOCKSHandler::SendUpstreamRequest()
{
LogPrint(eLogInfo, "SOCKS: negotiating with upstream proxy");
LogPrint(eLogInfo, "SOCKS: Negotiating with upstream proxy");
EnterState(UPSTREAM_HANDSHAKE);
if (m_upstreamSock) {
boost::asio::write(*m_upstreamSock, GenerateUpstreamRequest());
AsyncUpstreamSockRead();
} else {
LogPrint(eLogError, "SOCKS: no upstream socket to send handshake to");
LogPrint(eLogError, "SOCKS: No upstream socket to send handshake to");
}
}
void SOCKSHandler::HandleUpstreamConnected(const boost::system::error_code & ecode, boost::asio::ip::tcp::resolver::iterator itr)
{
if (ecode) {
LogPrint(eLogWarning, "SOCKS: could not connect to upstream proxy: ", ecode.message());
LogPrint(eLogWarning, "SOCKS: Could not connect to upstream proxy: ", ecode.message());
SocksRequestFailed(SOCKS5_NET_UNREACH);
return;
}
LogPrint(eLogInfo, "SOCKS: connected to upstream proxy");
LogPrint(eLogInfo, "SOCKS: Connected to upstream proxy");
SendUpstreamRequest();
}
@ -775,11 +775,11 @@ namespace proxy
{
if (ecode) {
// error resolving
LogPrint(eLogWarning, "SOCKS: upstream proxy", m_UpstreamProxyAddress, " not resolved: ", ecode.message());
LogPrint(eLogWarning, "SOCKS: Upstream proxy", m_UpstreamProxyAddress, " not resolved: ", ecode.message());
SocksRequestFailed(SOCKS5_NET_UNREACH);
return;
}
LogPrint(eLogInfo, "SOCKS: upstream proxy resolved");
LogPrint(eLogInfo, "SOCKS: Upstream proxy resolved");
EnterState(UPSTREAM_CONNECT);
auto & service = GetOwner()->GetService();
m_upstreamSock = std::make_shared<boost::asio::ip::tcp::socket>(service);