X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Firc%2F__init__.py;h=6dfdc5d907e3ef07fb7b5cdc440ecbea5ff94453;hb=52f5d527c5f931328aaaf96fa2bb993084d8edfe;hp=9c9a61f93a05d88207cdf46b958dd72ef28a5d5b;hpb=ead428133a5b419021153d8cbb27603053ea4cf4;p=electrum-server.git diff --git a/backends/irc/__init__.py b/backends/irc/__init__.py index 9c9a61f..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 @@ -99,13 +101,12 @@ 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) break - self.message += data while self.message.find('\n') != -1: @@ -115,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: @@ -135,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()]}) @@ -156,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) @@ -179,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') @@ -201,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)