diff --git a/src/console_commands.cpp b/src/console_commands.cpp index 233240f..48922f7 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -358,7 +358,7 @@ void ConsoleCommands::stdinReadCallback(uv_stream_t* stream, ssize_t nread, cons } -void ConsoleCommands::process_input(std::string& command, char* data, uint32_t size) +void ConsoleCommands::process_input(std::string& command, const char* data, uint32_t size) { command.append(data, size); diff --git a/src/console_commands.h b/src/console_commands.h index e6d570e..77e8ba1 100644 --- a/src/console_commands.h +++ b/src/console_commands.h @@ -40,7 +40,7 @@ public: size_t size() const override { return sizeof(ConsoleClient); } bool on_connect() override { return true; }; - bool on_read(char* data, uint32_t size) override { static_cast(m_owner)->process_input(m_command, data, size); return true; }; + bool on_read(const char* data, uint32_t size) override { static_cast(m_owner)->process_input(m_command, data, size); return true; }; char m_consoleReadBuf[1024] = {}; @@ -66,7 +66,7 @@ private: static void allocCallback(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); static void stdinReadCallback(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); - void process_input(std::string& command, char* data, uint32_t size); + void process_input(std::string& command, const char* data, uint32_t size); }; } // namespace p2pool diff --git a/src/merge_mining_client_tari.cpp b/src/merge_mining_client_tari.cpp index 144c766..f9aa533 100644 --- a/src/merge_mining_client_tari.cpp +++ b/src/merge_mining_client_tari.cpp @@ -574,7 +574,7 @@ bool MergeMiningClientTari::TariClient::on_connect() return true; } -bool MergeMiningClientTari::TariClient::on_read(char* data, uint32_t size) +bool MergeMiningClientTari::TariClient::on_read(const char* data, uint32_t size) { MergeMiningClientTari::TariServer* server = static_cast(m_owner); if (!server) { diff --git a/src/merge_mining_client_tari.h b/src/merge_mining_client_tari.h index 0ce51c5..197181b 100644 --- a/src/merge_mining_client_tari.h +++ b/src/merge_mining_client_tari.h @@ -98,7 +98,7 @@ private: void reset() override; [[nodiscard]] bool on_connect() override; - [[nodiscard]] bool on_read(char* data, uint32_t size) override; + [[nodiscard]] bool on_read(const char* data, uint32_t size) override; char m_buf[BUF_SIZE]; std::vector m_pendingData; diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index ab3e0c7..fc836c0 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -1496,7 +1496,7 @@ bool P2PServer::P2PClient::on_connect() return send_handshake_challenge(); } -bool P2PServer::P2PClient::on_read(char* data, uint32_t size) +bool P2PServer::P2PClient::on_read(const char* data, uint32_t size) { P2PServer* server = static_cast(m_owner); if (!server) { diff --git a/src/p2p_server.h b/src/p2p_server.h index 7433414..ea5e91c 100644 --- a/src/p2p_server.h +++ b/src/p2p_server.h @@ -79,7 +79,7 @@ public: void reset() override; [[nodiscard]] bool on_connect() override; - [[nodiscard]] bool on_read(char* data, uint32_t size) override; + [[nodiscard]] bool on_read(const char* data, uint32_t size) override; void on_read_failed(int err) override; void on_disconnected() override; diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 51c46ed..151e7c0 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -1171,7 +1171,7 @@ bool StratumServer::StratumClient::on_connect() return true; } -bool StratumServer::StratumClient::on_read(char* data, uint32_t size) +bool StratumServer::StratumClient::on_read(const char* data, uint32_t size) { #ifdef WITH_TLS if (!m_tlsChecked) { @@ -1186,7 +1186,7 @@ bool StratumServer::StratumClient::on_read(char* data, uint32_t size) } #endif - auto on_parse = [this](char* data, uint32_t size) { + auto on_parse = [this](const char* data, uint32_t size) { if (static_cast(m_stratumReadBufBytes) + size > STRATUM_BUF_SIZE) { LOGWARN(4, "client " << static_cast(m_addrString) << " sent too long Stratum message"); ban(DEFAULT_BAN_TIME); diff --git a/src/stratum_server.h b/src/stratum_server.h index 84257ef..bc0b8b2 100644 --- a/src/stratum_server.h +++ b/src/stratum_server.h @@ -47,7 +47,7 @@ public: void reset() override; [[nodiscard]] bool on_connect() override; - [[nodiscard]] bool on_read(char* data, uint32_t size) override; + [[nodiscard]] bool on_read(const char* data, uint32_t size) override; [[nodiscard]] bool process_request(char* data, uint32_t size); [[nodiscard]] bool process_login(rapidjson::Document& doc, uint32_t id); diff --git a/src/tcp_server.cpp b/src/tcp_server.cpp index 9d96cbd..a620057 100644 --- a/src/tcp_server.cpp +++ b/src/tcp_server.cpp @@ -1107,7 +1107,7 @@ void TCPServer::Client::on_read(uv_stream_t* stream, ssize_t nread, const uv_buf } } -bool TCPServer::Client::on_proxy_handshake(char* data, uint32_t size) +bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size) { if ((data != m_readBuf + m_numRead) || (data + size > m_readBuf + m_readBufSize)) { LOGERR(1, "peer " << static_cast(m_addrString) << " invalid data pointer or size in on_read()"); diff --git a/src/tcp_server.h b/src/tcp_server.h index 262ed06..946f792 100644 --- a/src/tcp_server.h +++ b/src/tcp_server.h @@ -63,8 +63,8 @@ public: virtual void reset(); [[nodiscard]] virtual bool on_connect() = 0; - [[nodiscard]] virtual bool on_read(char* data, uint32_t size) = 0; - [[nodiscard]] bool on_proxy_handshake(char* data, uint32_t size); + [[nodiscard]] virtual bool on_read(const char* data, uint32_t size) = 0; + [[nodiscard]] bool on_proxy_handshake(const char* data, uint32_t size); virtual void on_read_failed(int /*err*/) {} virtual void on_disconnected() {} diff --git a/src/tls.cpp b/src/tls.cpp index 5d4aa5e..47f42ed 100644 --- a/src/tls.cpp +++ b/src/tls.cpp @@ -217,7 +217,7 @@ bool ServerTls::init() return true; } -bool ServerTls::on_read_internal(char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback) +bool ServerTls::on_read_internal(const char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback) { SSL* ssl = m_ssl.get(); if (!ssl) { diff --git a/src/tls.h b/src/tls.h index e4387ac..10f9112 100644 --- a/src/tls.h +++ b/src/tls.h @@ -43,7 +43,7 @@ public: [[nodiscard]] bool init(); template - [[nodiscard]] FORCEINLINE bool on_read(char* data, uint32_t size, T&& read_callback, U&& write_callback) + [[nodiscard]] FORCEINLINE bool on_read(const char* data, uint32_t size, T&& read_callback, U&& write_callback) { return on_read_internal(data, size, ReadCallback::Derived(std::move(read_callback)), WriteCallback::Derived(std::move(write_callback))); } @@ -60,7 +60,7 @@ private: typedef Callback ReadCallback; typedef Callback WriteCallback; - [[nodiscard]] bool on_read_internal(char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback); + [[nodiscard]] bool on_read_internal(const char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback); [[nodiscard]] bool on_write_internal(const uint8_t* data, size_t size, WriteCallback::Base&& write_callback); private: