diff --git a/src/net/Client.cpp b/src/net/Client.cpp index a023ef38..9c7f373e 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -55,6 +55,7 @@ int64_t Client::m_sequence = 1; Client::Client(int id, const char *agent, IClientListener *listener) : m_ipv6(false), + m_nicehash(false), m_quiet(false), m_agent(agent), m_listener(listener), @@ -220,7 +221,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code) return false; } - Job job(m_id, m_url.isNicehash(), m_url.isMonero()); + Job job(m_id, m_nicehash, m_url.isMonero()); if (!job.setId(params["job_id"].GetString())) { *code = 3; return false; @@ -257,6 +258,12 @@ bool Client::parseLogin(const rapidjson::Value &result, int *code) return false; } + m_nicehash = m_url.isNicehash(); + + if (result.HasMember("extensions")) { + parseExtensions(result["extensions"]); + } + return parseJob(result["job"], code); } @@ -419,6 +426,24 @@ void Client::parse(char *line, size_t len) } +void Client::parseExtensions(const rapidjson::Value &value) +{ + if (!value.IsArray()) { + return; + } + + for (const rapidjson::Value &ext : value.GetArray()) { + if (!ext.IsString()) { + continue; + } + + if (strcmp(ext.GetString(), "nicehash") == 0) { + m_nicehash = true; + } + } +} + + void Client::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error) { if (error.IsObject()) { diff --git a/src/net/Client.h b/src/net/Client.h index db480461..a927bd19 100644 --- a/src/net/Client.h +++ b/src/net/Client.h @@ -86,6 +86,7 @@ private: void connect(sockaddr *addr); void login(); void parse(char *line, size_t len); + void parseExtensions(const rapidjson::Value &value); void parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error); void parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error); void ping(); @@ -103,6 +104,7 @@ private: addrinfo m_hints; bool m_ipv6; + bool m_nicehash; bool m_quiet; char m_buf[2048]; char m_ip[46];