X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Firc%2F__init__.py;h=6dfdc5d907e3ef07fb7b5cdc440ecbea5ff94453;hb=52f5d527c5f931328aaaf96fa2bb993084d8edfe;hp=cf830b95e5195686ff6b97e3e07258b9c5c25e72;hpb=1751c457609209877431311c54e48278947b4ad7;p=electrum-server.git diff --git a/backends/irc/__init__.py b/backends/irc/__init__.py index cf830b9..6dfdc5d 100644 --- a/backends/irc/__init__.py +++ b/backends/irc/__init__.py @@ -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 @@ -114,15 +116,16 @@ 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') - elif '353' in line: # answer to /names + elif '353' in line[1]: # answer to /names k = line.index('353') for item in line[k+1:]: if item.startswith(self.prepend): out_msg.append('WHO %s\n' % item) - elif '352' in line: # answer to /who + elif '352' in line[1]: # answer to /who # warning: this is a horrible hack which apparently works k = line.index('352') try: @@ -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[1]: + 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)