def cb(ret_tuple): # FIXME: This is not run in a thread, so it hangs the system if connecting takes a while. success, response = ret_tuple if not success: self.bd.get_object("act_toggle_logging").set_active(False) return s, r = self.log_rcon(server, 'log', False) if 'not currently logging' in r: self.log_rcon(server, 'log on', False) def after_fetch_ip(ip): if not ip: return for port in xrange(27020,27100): try: self.loggers[server] = reactor.listenUDP(port, SourceLib.SourceLog.SourceLogListener(server.ip, server.port, serverlogger.GameserverLogger(self, server))) for line in response.split('\n'): if ip in line and str(port) not in line: self.log_rcon(server, 'logaddress_del ' + line, False) self.log_rcon(server, 'logaddress_add ' + self.get_sid(ip, port), False) statusmanager.push_status("Enabled logging from "+self.get_server_sid(server)+".") break except twisted.internet.error.CannotListenError: print("Could not bind to port "+ str(port) + ", trying "+str(port+1)) ret, thread = utils.whatismyip() if thread: ret.addCallback(after_fetch_ip) else: after_fetch_ip(ret)
def cb(ret_tuple): # FIXME: This is not run in a thread, so it hangs the system if connecting takes a while. success, response = ret_tuple if not success: self.bd.get_object("act_toggle_logging").set_active(False) return s, r = self.log_rcon(server, 'log', False) if 'not currently logging' in r: self.log_rcon(server, 'log on', False) def after_fetch_ip(ip): if not ip: return for port in xrange(27020, 27100): try: self.loggers[server] = reactor.listenUDP( port, SourceLib.SourceLog.SourceLogListener( server.ip, server.port, serverlogger.GameserverLogger(self, server))) for line in response.split('\n'): if ip in line and str(port) not in line: self.log_rcon(server, 'logaddress_del ' + line, False) self.log_rcon( server, 'logaddress_add ' + self.get_sid(ip, port), False) statusmanager.push_status("Enabled logging from " + self.get_server_sid(server) + ".") break except twisted.internet.error.CannotListenError: print("Could not bind to port " + str(port) + ", trying " + str(port + 1)) ret, thread = utils.whatismyip() if thread: ret.addCallback(after_fetch_ip) else: after_fetch_ip(ret)
#!/usr/bin/env python import SourceLib.SourceLog import utils import asyncore class parser(SourceLib.SourceLog.SourceLogParser): def action(self, remote, timestamp, key, value, properties): print (remote, timestamp, key, value, properties) print ("hi") def parse(self, line): SourceLib.SourceLog.SourceLogParser.parse(self, line) print(line.strip('\x00\xff\r\n\t')) ip = utils.whatismyip() rcon = SourceLib.SourceRcon.SourceRcon('fun.critsandvich.com', 27015, 'xe7Zsg') print (rcon.rcon("logaddress_add " + ip + ":" + "27020")) print (rcon.rcon("log")) listener = SourceLib.SourceLog.SourceLogListener(('', 27020), ('fun.critsandvich.com',27015), parser()) asyncore.loop()
#!/usr/bin/env python import SourceLib.SourceLog import utils import asyncore class parser(SourceLib.SourceLog.SourceLogParser): def action(self, remote, timestamp, key, value, properties): print(remote, timestamp, key, value, properties) print("hi") def parse(self, line): SourceLib.SourceLog.SourceLogParser.parse(self, line) print(line.strip('\x00\xff\r\n\t')) ip = utils.whatismyip() rcon = SourceLib.SourceRcon.SourceRcon('fun.critsandvich.com', 27015, 'xe7Zsg') print(rcon.rcon("logaddress_add " + ip + ":" + "27020")) print(rcon.rcon("log")) listener = SourceLib.SourceLog.SourceLogListener( ('', 27020), ('fun.critsandvich.com', 27015), parser()) asyncore.loop()