Log KICK messages from IRC
[electrum-server.git] / backends / irc / __init__.py
index 4732175..1f58f77 100644 (file)
@@ -72,6 +72,7 @@ class IrcThread(threading.Thread):
 
     def run(self):
         ircname = self.getname()
+        print_log("joining IRC")
 
         while not self.processor.shared.stopped():
             try:
@@ -80,6 +81,7 @@ class IrcThread(threading.Thread):
                 s.settimeout(0.1)
             except:
                 s.close()
+                print_log("IRC: reconnect in 10 s")
                 time.sleep(10)
                 continue
 
@@ -99,7 +101,7 @@ class IrcThread(threading.Thread):
                         if out_msg:
                             m = out_msg.pop(0)
                             s.send(m)
-                            continue
+                        continue
                     except:
                         print_log( "irc: socket error" )
                         time.sleep(1)
@@ -114,6 +116,7 @@ class IrcThread(threading.Thread):
                         line = line.strip('\r')
                         if not line:
                             continue
+                        # print_log("<--", line)
                         line = line.split()
                         if line[0] == 'PING':
                             out_msg.append('PONG ' + line[1] + '\n')
@@ -134,6 +137,11 @@ class IrcThread(threading.Thread):
                             host = line[k+9]
                             ports = line[k+10:]
                             self.peers[name] = (ip, host, ports)
+                        elif 'KICK' in line:
+                            try:
+                                print_log("KICK", line[3] + line[4])
+                            except:
+                                print_log("KICK", "error")
 
                     if time.time() - t > 5*60:
                         #self.processor.push_response({'method': 'server.peers', 'params': [self.get_peers()]})
@@ -155,7 +163,6 @@ class ServerProcessor(Processor):
         Processor.__init__(self)
         self.daemon = True
         self.banner = config.get('server', 'banner')
-        self.password = config.get('server', 'password')
 
         if config.get('server', 'irc') == 'yes':
             self.irc = IrcThread(self, config)
@@ -178,19 +185,6 @@ class ServerProcessor(Processor):
         params = request['params']
         result = None
 
-        if method in ['server.stop', 'server.info', 'server.debug']:
-            try:
-                password = request['params'][0]
-            except:
-                password = None
-
-            if password != self.password:
-                self.push_response(session, 
-                                   {'id': request['id'],
-                                    'result': None,
-                                    'error': 'incorrect password'})
-                return
-
         if method == 'server.banner':
             result = self.banner.replace('\\n', '\n')
 
@@ -200,32 +194,6 @@ class ServerProcessor(Processor):
         elif method == 'server.version':
             result = VERSION
 
-        elif method == 'server.stop':
-            self.shared.stop()
-            result = 'stopping, please wait until all threads terminate.'
-
-        elif method == 'server.info':
-            result = map(lambda s: {"time": s.time,
-                                    "name": s.name,
-                                    "address": s.address,
-                                    "version": s.version,
-                                    "subscriptions": len(s.subscriptions)},
-                         self.dispatcher.request_dispatcher.get_sessions())
-
-        elif method == 'server.debug':
-            try:
-                s = request['params'][1]
-            except:
-                s = None
-
-            if s:
-                from guppy import hpy
-                h = hpy()
-                bp = self.dispatcher.request_dispatcher.processors['blockchain']
-                try:
-                    result = str(eval(s))
-                except:
-                    result = "error"
         else:
             print_log("unknown method", method)