From 8fc232a8202dd6c6b99a368bc5062da67bc8b977 Mon Sep 17 00:00:00 2001 From: Alan Penner Date: Sun, 26 Jan 2014 20:17:21 -0800 Subject: [PATCH 1/4] print IP address of invalid workers --- mining/service.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mining/service.py b/mining/service.py index f90c2bd..886e984 100644 --- a/mining/service.py +++ b/mining/service.py @@ -116,14 +116,15 @@ class MiningService(GenericService): session.setdefault('authorized', {}) # Check if worker is authorized to submit shares + ip = self.connection_ref()._get_ip() if not Interfaces.worker_manager.authorize(worker_name, session['authorized'].get(worker_name)): - raise SubmitException("Worker is not authorized") + raise SubmitException("Worker is not authorized: IP %s", str(ip)) # Check if extranonce1 is in connection session extranonce1_bin = session.get('extranonce1', None) if not extranonce1_bin: - raise SubmitException("Connection is not subscribed for mining") + raise SubmitException("Connection is not subscribed for mining: %s", str(ip)) # Get current block job_id difficulty = session['difficulty'] @@ -136,7 +137,7 @@ class MiningService(GenericService): #log.debug("worker_job_log: %s" % repr(Interfaces.worker_manager.job_log)) submit_time = Interfaces.timestamper.time() - ip = self.connection_ref()._get_ip() + (valid, invalid, is_banned, diff, is_ext_diff, last_ts) = Interfaces.worker_manager.worker_log['authorized'][worker_name] percent = float(float(invalid) / (float(valid) if valid else 1) * 100) From 558cf7a17fafb80d1eb1544b9a509c0858dde63a Mon Sep 17 00:00:00 2001 From: Alan Penner Date: Sun, 26 Jan 2014 20:25:20 -0800 Subject: [PATCH 2/4] fix error messages --- mining/service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mining/service.py b/mining/service.py index 886e984..4f7f4e4 100644 --- a/mining/service.py +++ b/mining/service.py @@ -118,13 +118,13 @@ class MiningService(GenericService): # Check if worker is authorized to submit shares ip = self.connection_ref()._get_ip() if not Interfaces.worker_manager.authorize(worker_name, session['authorized'].get(worker_name)): - raise SubmitException("Worker is not authorized: IP %s", str(ip)) + raise SubmitException("Worker is not authorized: IP "+str(ip)) # Check if extranonce1 is in connection session extranonce1_bin = session.get('extranonce1', None) if not extranonce1_bin: - raise SubmitException("Connection is not subscribed for mining: %s", str(ip)) + raise SubmitException("Connection is not subscribed for mining: %s"+str(ip)) # Get current block job_id difficulty = session['difficulty'] From 62befe0168f77592f2ee24a26fdcd0074c54ffe3 Mon Sep 17 00:00:00 2001 From: Alan Penner Date: Sun, 26 Jan 2014 20:29:06 -0800 Subject: [PATCH 3/4] log ip instead of throw it in exception --- mining/service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mining/service.py b/mining/service.py index 4f7f4e4..c65cfd2 100644 --- a/mining/service.py +++ b/mining/service.py @@ -118,13 +118,15 @@ class MiningService(GenericService): # Check if worker is authorized to submit shares ip = self.connection_ref()._get_ip() if not Interfaces.worker_manager.authorize(worker_name, session['authorized'].get(worker_name)): - raise SubmitException("Worker is not authorized: IP "+str(ip)) + log.info("Worker is not authorized: IP %s", str(ip)) + raise SubmitException("Worker is not authorized") # Check if extranonce1 is in connection session extranonce1_bin = session.get('extranonce1', None) if not extranonce1_bin: - raise SubmitException("Connection is not subscribed for mining: %s"+str(ip)) + log.info("Connection is not subscribed for mining: IP %s", str(ip)) + raise SubmitException("Connection is not subscribed for mining") # Get current block job_id difficulty = session['difficulty'] From 06e2d03a9c264b711713126706aebb2dfeea2cdd Mon Sep 17 00:00:00 2001 From: Alan Penner Date: Sun, 26 Jan 2014 20:33:08 -0800 Subject: [PATCH 4/4] add log of IP in authorize --- mining/service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mining/service.py b/mining/service.py index c65cfd2..6cb2efb 100644 --- a/mining/service.py +++ b/mining/service.py @@ -90,6 +90,8 @@ class MiningService(GenericService): Interfaces.worker_manager.worker_log['authorized'][worker_name] = (0, 0, False, session['difficulty'], is_ext_diff, Interfaces.timestamper.time()) return True else: + ip = self.connection_ref()._get_ip() + log.info("Failed worker authorization: IP %s", str(ip)) if worker_name in session['authorized']: del session['authorized'][worker_name] if worker_name in Interfaces.worker_manager.worker_log['authorized']: