Show resolved pool ip.

This commit is contained in:
XMRig 2017-07-02 01:36:33 +03:00
parent 8ec58a8394
commit 71522214ae
4 changed files with 9 additions and 4 deletions

View file

@ -122,7 +122,7 @@ else()
endif() endif()
add_definitions(/DUNICODE) add_definitions(/DUNICODE)
add_definitions(/DAPP_DEBUG) #add_definitions(/DAPP_DEBUG)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

View file

@ -50,6 +50,7 @@ Client::Client(int id, const char *agent, IClientListener *listener) :
m_stream(nullptr), m_stream(nullptr),
m_socket(nullptr) m_socket(nullptr)
{ {
memset(m_ip, 0, sizeof(m_ip));
m_resolver.data = m_responseTimer.data = m_retriesTimer.data = m_keepAliveTimer.data = this; m_resolver.data = m_responseTimer.data = m_retriesTimer.data = m_keepAliveTimer.data = this;
m_hints.ai_family = PF_INET; m_hints.ai_family = PF_INET;
@ -513,6 +514,8 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
return client->reconnect();; return client->reconnect();;
} }
uv_ip4_name(reinterpret_cast<sockaddr_in*>(res->ai_addr), client->m_ip, 16);
client->connect(res->ai_addr); client->connect(res->ai_addr);
uv_freeaddrinfo(res); uv_freeaddrinfo(res);
} }

View file

@ -63,6 +63,7 @@ public:
inline bool isReady() const { return m_state == ConnectedState && m_failures == 0; } inline bool isReady() const { return m_state == ConnectedState && m_failures == 0; }
inline const char *host() const { return m_url.host(); } inline const char *host() const { return m_url.host(); }
inline const char *ip() const { return m_ip; }
inline const Job &job() const { return m_job; } inline const Job &job() const { return m_job; }
inline int id() const { return m_id; } inline int id() const { return m_id; }
inline SocketState state() const { return m_state; } inline SocketState state() const { return m_state; }
@ -96,6 +97,7 @@ private:
static Client *getClient(void *data); static Client *getClient(void *data);
bool m_quiet; bool m_quiet;
char m_ip[17];
char m_rpcId[64]; char m_rpcId[64];
const char *m_agent; const char *m_agent;
IClientListener *m_listener; IClientListener *m_listener;

View file

@ -78,7 +78,7 @@ void Network::onActive(Client *client)
return; return;
} }
LOG_INFO(m_options->colors() ? "\x1B[01;37muse pool: \x1B[01;36m%s:%d" : "use pool: %s:%d", client->host(), client->port()); LOG_INFO(m_options->colors() ? "\x1B[01;37muse pool \x1B[01;36m%s:%d \x1B[01;30m%s" : "use pool %s:%d %s", client->host(), client->port(), client->ip());
} }
@ -121,11 +121,11 @@ void Network::onPause(IStrategy *strategy)
void Network::setJob(Client *client, const Job &job) void Network::setJob(Client *client, const Job &job)
{ {
if (m_options->colors()) { if (m_options->colors()) {
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff: \x1B[01;37m%d", client->host(), client->port(), job.diff()); LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff \x1B[01;37m%d", client->host(), client->port(), job.diff());
} }
else { else {
LOG_INFO("new job from %s:%d diff: %d", client->host(), client->port(), job.diff()); LOG_INFO("new job from %s:%d diff %d", client->host(), client->port(), job.diff());
} }
Workers::setJob(job); Workers::setJob(job);