check password for 'info' command. display version and load
[electrum-server.git] / backends / irc / __init__.py
index 4d3c448..099c7c7 100644 (file)
@@ -76,7 +76,7 @@ class ServerProcessor(Processor):
                         ports  = line[k+10:]
                         self.peers[name] = (ip, host, ports)
                     if time.time() - t > 5*60:
-                        self.push_response({'method':'server.peers', 'result':[self.get_peers()]})
+                        self.push_response({'method':'server.peers', 'params':[self.get_peers()]})
                         s.send('NAMES #electrum\n')
                         t = time.time()
                         self.peers = {}
@@ -93,6 +93,17 @@ class ServerProcessor(Processor):
         params = request['params']
         result = None
 
+        if method in ['server.stop', 'server.info']:
+            try:
+                password = request['params'][0]
+            except:
+                password = None
+
+            if password != self.password:
+                response = { 'id':request['id'], 'result':None,  'error':'incorrect password'}
+                self.push_response(response)
+                return
+
         if method == 'server.banner':
             result = self.banner.replace('\\n','\n')
 
@@ -103,14 +114,12 @@ class ServerProcessor(Processor):
             pass
 
         elif method == 'server.stop':
-            print "stopping..."
-            try:
-                password = request['params'][0]
-            except:
-                password = None
-            if password == self.password:
-                self.shared.stop()
-                result = 'ok'
+            self.shared.stop()
+            result = 'ok'
+
+        elif method == 'server.info':
+            result = map(lambda s: { "address":s.address, "version":s.version, "subscriptions":len(s.subscriptions)}, self.dispatcher.request_dispatcher.sessions)
+
         else:
             print "unknown method", request