mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-09-02 03:10:23 +01:00
implement PING command
Some checks failed
Build Debian packages / bookworm (push) Has been cancelled
Build Debian packages / bullseye (push) Has been cancelled
Build Debian packages / trixie (push) Has been cancelled
Build on FreeBSD / with UPnP (push) Has been cancelled
Build on OSX / With USE_UPNP=no (push) Has been cancelled
Build on OSX / With USE_UPNP=yes (push) Has been cancelled
Build on Windows / clang-x86_64 (push) Has been cancelled
Build on Windows / i686 (push) Has been cancelled
Build on Windows / ucrt-x86_64 (push) Has been cancelled
Build on Windows / x86_64 (push) Has been cancelled
Build on Windows / CMake clang-x86_64 (push) Has been cancelled
Build on Windows / CMake i686 (push) Has been cancelled
Build on Windows / CMake ucrt-x86_64 (push) Has been cancelled
Build on Windows / CMake x86_64 (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=no (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=yes (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Has been cancelled
Build containers / Building container for linux/amd64 (push) Has been cancelled
Build containers / Building container for linux/arm64 (push) Has been cancelled
Build containers / Building container for linux/arm/v7 (push) Has been cancelled
Build containers / Building container for linux/386 (push) Has been cancelled
Build containers / Pushing merged manifest (push) Has been cancelled
Some checks failed
Build Debian packages / bookworm (push) Has been cancelled
Build Debian packages / bullseye (push) Has been cancelled
Build Debian packages / trixie (push) Has been cancelled
Build on FreeBSD / with UPnP (push) Has been cancelled
Build on OSX / With USE_UPNP=no (push) Has been cancelled
Build on OSX / With USE_UPNP=yes (push) Has been cancelled
Build on Windows / clang-x86_64 (push) Has been cancelled
Build on Windows / i686 (push) Has been cancelled
Build on Windows / ucrt-x86_64 (push) Has been cancelled
Build on Windows / x86_64 (push) Has been cancelled
Build on Windows / CMake clang-x86_64 (push) Has been cancelled
Build on Windows / CMake i686 (push) Has been cancelled
Build on Windows / CMake ucrt-x86_64 (push) Has been cancelled
Build on Windows / CMake x86_64 (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=no (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=yes (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Has been cancelled
Build containers / Building container for linux/amd64 (push) Has been cancelled
Build containers / Building container for linux/arm64 (push) Has been cancelled
Build containers / Building container for linux/arm/v7 (push) Has been cancelled
Build containers / Building container for linux/386 (push) Has been cancelled
Build containers / Pushing merged manifest (push) Has been cancelled
This commit is contained in:
parent
1d7c7ac148
commit
3522a3180b
2 changed files with 19 additions and 1 deletions
|
@ -248,6 +248,14 @@ namespace client
|
|||
char * separator = strchr (m_Buffer, ' ');
|
||||
if (separator)
|
||||
{
|
||||
// one word command
|
||||
if (std::string_view (m_Buffer, separator - m_Buffer) == SAM_PING)
|
||||
{
|
||||
ProcessPing ({ separator + 1, (size_t)(eol - separator - 1) });
|
||||
return;
|
||||
}
|
||||
|
||||
// two words command
|
||||
size_t l = 0;
|
||||
separator = strchr (separator + 1, ' ');
|
||||
if (separator)
|
||||
|
@ -955,6 +963,12 @@ namespace client
|
|||
SendSessionI2PError ("Wrong session type");
|
||||
}
|
||||
|
||||
void SAMSocket::ProcessPing (std::string_view text)
|
||||
{
|
||||
LogPrint (eLogDebug, "SAM: Ping ", text);
|
||||
SendReplyWithMessage (SAM_PONG, std::string (text));
|
||||
}
|
||||
|
||||
void SAMSocket::SendReplyWithMessage (const char * reply, const std::string & msg)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -85,12 +85,15 @@ namespace client
|
|||
const char SAM_VALUE_TRANSIENT[] = "TRANSIENT";
|
||||
const char SAM_VALUE_TRUE[] = "true";
|
||||
const char SAM_VALUE_FALSE[] = "false";
|
||||
|
||||
|
||||
constexpr std::string_view SAM_VALUE_STREAM { "STREAM" };
|
||||
constexpr std::string_view SAM_VALUE_DATAGRAM { "DATAGRAM" };
|
||||
constexpr std::string_view SAM_VALUE_RAW { "RAW" };
|
||||
constexpr std::string_view SAM_VALUE_MASTER { "MASTER" };
|
||||
|
||||
constexpr std::string_view SAM_PING { "PING" };
|
||||
const char SAM_PONG[] = "PONG %s\n";
|
||||
|
||||
constexpr int MAKE_SAM_VERSION_NUMBER (int major, int minor) { return major*10 + minor; }
|
||||
constexpr int MIN_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 0);
|
||||
constexpr int MAX_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 3);
|
||||
|
@ -153,6 +156,7 @@ namespace client
|
|||
void ProcessNamingLookup (std::string_view buf);
|
||||
void ProcessSessionAdd (std::string_view buf);
|
||||
void ProcessSessionRemove (std::string_view buf);
|
||||
void ProcessPing (std::string_view text);
|
||||
void SendReplyWithMessage (const char * reply, const std::string & msg);
|
||||
void SendSessionI2PError(const std::string & msg);
|
||||
void SendStreamI2PError(const std::string & msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue