mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Added a command line parameter to disable Stratum HTTP
This commit is contained in:
parent
2581b4c2da
commit
a4459d6207
6 changed files with 16 additions and 1 deletions
|
@ -34,6 +34,7 @@
|
||||||
--version Print p2pool's version and build details
|
--version Print p2pool's version and build details
|
||||||
--tls-cert file Load TLS certificate chain from "file" in the PEM format
|
--tls-cert file Load TLS certificate chain from "file" in the PEM format
|
||||||
--tls-cert-key file Load TLS certificate private key from "file" in the PEM format
|
--tls-cert-key file Load TLS certificate private key from "file" in the PEM format
|
||||||
|
--no-stratum-http Disable HTTP on Stratum ports
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example command line
|
### Example command line
|
||||||
|
|
|
@ -78,6 +78,7 @@ void p2pool_usage()
|
||||||
"--tls-cert file Load TLS certificate chain from \"file\" in the PEM format\n"
|
"--tls-cert file Load TLS certificate chain from \"file\" in the PEM format\n"
|
||||||
"--tls-cert-key file Load TLS certificate private key from \"file\" in the PEM format\n"
|
"--tls-cert-key file Load TLS certificate private key from \"file\" in the PEM format\n"
|
||||||
#endif
|
#endif
|
||||||
|
"--no-stratum-http Disable HTTP on Stratum ports\n"
|
||||||
"--help Show this help message\n\n"
|
"--help Show this help message\n\n"
|
||||||
"Example command line:\n\n"
|
"Example command line:\n\n"
|
||||||
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",
|
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",
|
||||||
|
|
|
@ -213,6 +213,11 @@ Params::Params(int argc, char* const argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "--no-stratum-http") == 0) {
|
||||||
|
m_enableStratumHTTP = false;
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "Unknown command line parameter %s\n\n", argv[i]);
|
fprintf(stderr, "Unknown command line parameter %s\n\n", argv[i]);
|
||||||
p2pool_usage();
|
p2pool_usage();
|
||||||
|
|
|
@ -96,6 +96,7 @@ struct Params
|
||||||
std::string m_tlsCert;
|
std::string m_tlsCert;
|
||||||
std::string m_tlsCertKey;
|
std::string m_tlsCertKey;
|
||||||
#endif
|
#endif
|
||||||
|
bool m_enableStratumHTTP = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace p2pool
|
} // namespace p2pool
|
||||||
|
|
|
@ -602,6 +602,11 @@ void StratumServer::reset_share_counters()
|
||||||
m_totalFailedShares = 0;
|
m_totalFailedShares = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StratumServer::http_enabled() const
|
||||||
|
{
|
||||||
|
return m_pool->params().m_enableStratumHTTP;
|
||||||
|
}
|
||||||
|
|
||||||
const char* StratumServer::get_log_category() const
|
const char* StratumServer::get_log_category() const
|
||||||
{
|
{
|
||||||
return log_category_prefix;
|
return log_category_prefix;
|
||||||
|
@ -1204,7 +1209,7 @@ bool StratumServer::StratumClient::on_read(const char* data, uint32_t size)
|
||||||
for (char *c = line_start + m_stratumReadBufBytes - size; c < e; ++c) {
|
for (char *c = line_start + m_stratumReadBufBytes - size; c < e; ++c) {
|
||||||
if (*c == '\n') {
|
if (*c == '\n') {
|
||||||
// Check if the line starts with "GET " or "HEAD" (an HTTP request)
|
// Check if the line starts with "GET " or "HEAD" (an HTTP request)
|
||||||
if (c - line_start >= 4) {
|
if (static_cast<StratumServer*>(m_owner)->http_enabled() && (c - line_start >= 4)) {
|
||||||
const uint32_t line_start_data = read_unaligned(reinterpret_cast<uint32_t*>(line_start));
|
const uint32_t line_start_data = read_unaligned(reinterpret_cast<uint32_t*>(line_start));
|
||||||
|
|
||||||
const bool is_http_get = (line_start_data == 0x20544547U);
|
const bool is_http_get = (line_start_data == 0x20544547U);
|
||||||
|
|
|
@ -102,6 +102,8 @@ public:
|
||||||
|
|
||||||
void reset_share_counters();
|
void reset_share_counters();
|
||||||
|
|
||||||
|
bool http_enabled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] const char* get_log_category() const override;
|
[[nodiscard]] const char* get_log_category() const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue