pass string_view instead const char *. EdDSA signature be default
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / trixie (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions

This commit is contained in:
orignal 2025-08-20 21:29:36 -04:00
parent 2716869af4
commit 51b58c952a
2 changed files with 27 additions and 40 deletions

View file

@ -343,14 +343,12 @@ namespace client
} }
} }
void BOBCommandSession::SendReplyOK (const char * msg) void BOBCommandSession::SendReplyOK (std::string_view msg)
{ {
std::ostream os(&m_SendBuffer); std::ostream os(&m_SendBuffer);
os << "OK"; os << "OK";
if(msg) if (!msg.empty ())
{
os << " " << msg; os << " " << msg;
}
os << std::endl; os << std::endl;
Send (); Send ();
} }
@ -366,7 +364,7 @@ namespace client
Send (); Send ();
} }
void BOBCommandSession::SendReplyError (const char * msg) void BOBCommandSession::SendReplyError (std::string_view msg)
{ {
std::ostream os(&m_SendBuffer); std::ostream os(&m_SendBuffer);
os << "ERROR " << msg << std::endl; os << "ERROR " << msg << std::endl;
@ -377,10 +375,10 @@ namespace client
{ {
std::ostream os(&m_SendBuffer); std::ostream os(&m_SendBuffer);
os << "BOB 00.00.10" << std::endl; os << "BOB 00.00.10" << std::endl;
SendReplyOK(); SendReplyOK(std::string_view()); // empty string
} }
void BOBCommandSession::SendRaw (const char * data) void BOBCommandSession::SendRaw (std::string_view data)
{ {
std::ostream os(&m_SendBuffer); std::ostream os(&m_SendBuffer);
os << data << std::endl; os << data << std::endl;
@ -575,9 +573,7 @@ namespace client
if (!dest) if (!dest)
{ {
m_Nickname = operand; m_Nickname = operand;
std::string msg ("Nickname set to "); SendReplyOK ({ "Nickname set to ", m_Nickname });
msg += m_Nickname;
SendReplyOK (msg.c_str ());
} }
else else
SendReplyError ("tunnel is active"); SendReplyError ("tunnel is active");
@ -602,11 +598,7 @@ namespace client
m_Nickname = operand; m_Nickname = operand;
} }
if (m_Nickname == operand) if (m_Nickname == operand)
{ SendReplyOK ({"Nickname set to ", m_Nickname});
std::string msg ("Nickname set to ");
msg += m_Nickname;
SendReplyOK (msg.c_str ());
}
else else
SendReplyError ("no nickname has been set"); SendReplyError ("no nickname has been set");
} }
@ -617,7 +609,7 @@ namespace client
void BOBCommandSession::NewkeysCommandHandler (const char * operand, size_t len) void BOBCommandSession::NewkeysCommandHandler (const char * operand, size_t len)
{ {
LogPrint (eLogDebug, "BOB: newkeys"); LogPrint (eLogDebug, "BOB: newkeys");
i2p::data::SigningKeyType signatureType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1; i2p::data::SigningKeyType signatureType = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519;
i2p::data::CryptoKeyType cryptoType = i2p::data::CRYPTO_KEY_TYPE_ELGAMAL; i2p::data::CryptoKeyType cryptoType = i2p::data::CRYPTO_KEY_TYPE_ELGAMAL;
if (*operand) if (*operand)
{ {
@ -639,14 +631,14 @@ namespace client
m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType, true); m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType, true);
SendReplyOK (m_Keys.GetPublic ()->ToBase64 ().c_str ()); SendReplyOK (m_Keys.GetPublic ()->ToBase64 ());
} }
void BOBCommandSession::SetkeysCommandHandler (const char * operand, size_t len) void BOBCommandSession::SetkeysCommandHandler (const char * operand, size_t len)
{ {
LogPrint (eLogDebug, "BOB: setkeys ", operand); LogPrint (eLogDebug, "BOB: setkeys ", operand);
if (*operand && m_Keys.FromBase64 (operand)) if (*operand && m_Keys.FromBase64 (operand))
SendReplyOK (m_Keys.GetPublic ()->ToBase64 ().c_str ()); SendReplyOK (m_Keys.GetPublic ()->ToBase64 ());
else else
SendReplyError ("invalid keys"); SendReplyError ("invalid keys");
} }
@ -655,7 +647,7 @@ namespace client
{ {
LogPrint (eLogDebug, "BOB: getkeys"); LogPrint (eLogDebug, "BOB: getkeys");
if (m_Keys.GetPublic ()) // keys are set ? if (m_Keys.GetPublic ()) // keys are set ?
SendReplyOK (m_Keys.ToBase64 ().c_str ()); SendReplyOK (m_Keys.ToBase64 ());
else else
SendReplyError ("keys are not set"); SendReplyError ("keys are not set");
} }
@ -664,7 +656,7 @@ namespace client
{ {
LogPrint (eLogDebug, "BOB: getdest"); LogPrint (eLogDebug, "BOB: getdest");
if (m_Keys.GetPublic ()) // keys are set ? if (m_Keys.GetPublic ()) // keys are set ?
SendReplyOK (m_Keys.GetPublic ()->ToBase64 ().c_str ()); SendReplyOK (m_Keys.GetPublic ()->ToBase64 ());
else else
SendReplyError ("keys are not set"); SendReplyError ("keys are not set");
} }
@ -770,7 +762,7 @@ namespace client
auto leaseSet = localDestination->FindLeaseSet (addr->identHash); auto leaseSet = localDestination->FindLeaseSet (addr->identHash);
if (leaseSet) if (leaseSet)
{ {
SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ().c_str ()); SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ());
return; return;
} }
} }
@ -779,7 +771,7 @@ namespace client
auto requstCallback = [s](std::shared_ptr<i2p::data::LeaseSet> ls) auto requstCallback = [s](std::shared_ptr<i2p::data::LeaseSet> ls)
{ {
if (ls) if (ls)
s->SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ()); s->SendReplyOK (ls->GetIdentity ()->ToBase64 ());
else else
s->SendReplyError ("LeaseSet Not found"); s->SendReplyError ("LeaseSet Not found");
}; };
@ -805,7 +797,7 @@ namespace client
} }
auto ls = i2p::data::netdb.FindLeaseSet (addr->identHash); auto ls = i2p::data::netdb.FindLeaseSet (addr->identHash);
if (ls) if (ls)
SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ()); SendReplyOK (ls->GetIdentity ()->ToBase64 ());
else else
SendReplyError ("Local LeaseSet Not found"); SendReplyError ("Local LeaseSet Not found");
} }
@ -888,7 +880,7 @@ namespace client
for (const auto& it: destinations) for (const auto& it: destinations)
{ {
BuildStatusLine(false, it.second, statusLine); BuildStatusLine(false, it.second, statusLine);
SendRaw(statusLine.c_str()); SendRaw(statusLine);
if(m_Nickname.compare(it.second->GetNickname()) == 0) if(m_Nickname.compare(it.second->GetNickname()) == 0)
sentCurrent = true; sentCurrent = true;
} }
@ -897,7 +889,7 @@ namespace client
// add the current tunnel to the list. // add the current tunnel to the list.
// this is for the incomplete tunnel which has not been started yet. // this is for the incomplete tunnel which has not been started yet.
BuildStatusLine(true, m_CurrentDestination, statusLine); BuildStatusLine(true, m_CurrentDestination, statusLine);
SendRaw(statusLine.c_str()); SendRaw(statusLine);
} }
SendReplyOK ("Listing done"); SendReplyOK ("Listing done");
} }
@ -908,14 +900,10 @@ namespace client
const char * value = strchr (operand, '='); const char * value = strchr (operand, '=');
if (value) if (value)
{ {
std::string msg ("option ");
*(const_cast<char *>(value)) = 0; *(const_cast<char *>(value)) = 0;
m_Options[operand] = value + 1; m_Options[operand] = value + 1;
msg += operand; SendReplyOK ({ "option ", operand, " set to ", value + 1 });
*(const_cast<char *>(value)) = '='; *(const_cast<char *>(value)) = '=';
msg += " set to ";
msg += value + 1;
SendReplyOK (msg.c_str ());
} }
else else
SendReplyError ("malformed"); SendReplyError ("malformed");
@ -933,7 +921,7 @@ namespace client
{ {
// tunnel destination exists // tunnel destination exists
BuildStatusLine(false, dest, statusLine); BuildStatusLine(false, dest, statusLine);
SendReplyOK(statusLine.c_str()); SendReplyOK(statusLine);
} }
else else
{ {
@ -941,7 +929,7 @@ namespace client
{ {
// tunnel is incomplete / has not been started yet // tunnel is incomplete / has not been started yet
BuildStatusLine(true, nullptr, statusLine); BuildStatusLine(true, nullptr, statusLine);
SendReplyOK(statusLine.c_str()); SendReplyOK(statusLine);
} }
else else
{ {
@ -960,15 +948,14 @@ namespace client
{ {
ss << " " << x.first; ss << " " << x.first;
} }
const std::string &str = ss.str(); SendReplyOK(ss.str ());
SendReplyOK(str.c_str());
} }
else else
{ {
auto it = helpStrings.find(operand); auto it = helpStrings.find(operand);
if (it != helpStrings.end ()) if (it != helpStrings.end ())
{ {
SendReplyOK(it->second.c_str()); SendReplyOK(it->second);
return; return;
} }
SendReplyError("No such command"); SendReplyError("No such command");

View file

@ -254,10 +254,10 @@ namespace client
void Send (); void Send ();
void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
void SendReplyOK (const char * msg = nullptr); void SendReplyOK (std::string_view msg);
void SendReplyOK (const std::vector<std::string_view>& strings); void SendReplyOK (const std::vector<std::string_view>& strings);
void SendReplyError (const char * msg); void SendReplyError (std::string_view msg);
void SendRaw (const char * data); void SendRaw (std::string_view data);
void BuildStatusLine(bool currentTunnel, std::shared_ptr<BOBDestination> destination, std::string &out); void BuildStatusLine(bool currentTunnel, std::shared_ptr<BOBDestination> destination, std::string &out);