def newConnection(self, request): ticket = login_optional(request) ip = request.getClientIP() nick = request.args.get("nick") if not nick: raise AJAXException, "Nickname not supplied." nick = ircclient.irc_decode(nick[0]) password = request.args.get("password") if password is not None: password = ircclient.irc_decode(password[0]) for i in xrange(10): id = get_session_id() if not Sessions.get(id): break else: raise IDGenerationException() session = IRCSession(id) qticket = getSessionData(request).get("qticket") if qticket is None: perform = None else: service_mask = config.AUTH_SERVICE msg_mask = service_mask.split("!")[0] + "@" + service_mask.split("@", 1)[1] perform = ["PRIVMSG %s :TICKETAUTH %s" % (msg_mask, qticket)] ident, realname = config.IDENT, config.REALNAME if ident is config_options.IDENT_HEX or ident is None: # latter is legacy ident = socket.inet_aton(ip).encode("hex") elif ident is config_options.IDENT_NICKNAME: ident = nick elif ident is config_options.IDENT_FORWARDED_USER: ident = request.getHeader(config.IDENT_FORWARDED_USER_HEADER) self.__connect_hit() def proceed(hostname): kwargs = dict(nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname) if password is not None: kwargs["password"] = password client = ircclient.createIRC(session, **kwargs) session.client = client if not hasattr(config, "WEBIRC_MODE") or config.WEBIRC_MODE == "hmac": proceed(None) elif config.WEBIRC_MODE != "hmac": notice = lambda x: session.event(connect_notice(x)) notice("Looking up your hostname...") def callback(hostname): notice("Found your hostname.") proceed(hostname) def errback(failure): notice("Couldn't look up your hostname!") proceed(ip) qdns.lookupAndVerifyPTR(ip, timeout=[config.DNS_TIMEOUT]).addCallbacks(callback, errback) Sessions[id] = session return id
def newConnection(self, request): ticket = login_optional(request) ip = request.getClientIP() nick = request.args.get("nick") if not nick: raise AJAXException, "Nickname not supplied." nick = ircclient.irc_decode(nick[0]) password = request.args.get("password") if password is not None: password = ircclient.irc_decode(password[0]) for i in range(10): id = get_session_id() if not Sessions.get(id): break else: raise IDGenerationException() session = IRCSession(id) qticket = getSessionData(request).get("qticket") if qticket is None: perform = None else: service_mask = config.AUTH_SERVICE msg_mask = service_mask.split("!")[0] + "@" + service_mask.split( "@", 1)[1] perform = ["PRIVMSG %s :TICKETAUTH %s" % (msg_mask, qticket)] ident, realname = config.IDENT, config.REALNAME if ident is config_options.IDENT_HEX or ident is None: # latter is legacy ident = socket.inet_aton(ip).encode("hex") elif ident is config_options.IDENT_NICKNAME: ident = nick self.__connect_hit() def proceed(hostname): kwargs = dict(nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname) if password is not None: kwargs["password"] = password client = ircclient.createIRC(session, **kwargs) session.client = client if not hasattr(config, "WEBIRC_MODE") or config.WEBIRC_MODE == "hmac": proceed(None) elif config.WEBIRC_MODE != "hmac": notice = lambda x: session.event(connect_notice(x)) notice("Looking up your hostname...") def callback(hostname): notice("Found your hostname.") proceed(hostname) def errback(failure): notice("Couldn't look up your hostname!") proceed(ip) qdns.lookupAndVerifyPTR(ip, timeout=[config.DNS_TIMEOUT]).addCallbacks( callback, errback) Sessions[id] = session return json.dumps((True, id, TRANSPORTS))
def newConnection(self, request): ip = request.getClientIP() nick = request.args.get("nick") if not nick: raise AJAXException, "Nickname not supplied." nick = ircclient.irc_decode(nick[0]) password = request.args.get("password") if password is not None: password = ircclient.irc_decode(password[0]) authUser = request.args.get("authUser") if authUser is not None: authUser = ircclient.irc_decode(authUser[0]) authSecret = request.args.get("authSecret") if authSecret is not None: authSecret = ircclient.irc_decode(authSecret[0]) for i in xrange(10): id = get_session_id() if not Sessions.get(id): break else: raise IDGenerationException() session = IRCSession(id) perform = None ident, realname = config.irc["ident_string"], config.irc["realname"] if config.irc["ident"] == "hex": ident = socket.inet_aton(ip).encode("hex") elif config.irc["ident"] == "nick": ident = nick self.__connect_hit() def proceed(hostname): kwargs = dict(nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname) if password is not None: kwargs["password"] = password if ((authUser is not None) and (authSecret is not None)): kwargs["authUser"] = authUser kwargs["authSecret"] = authSecret client = ircclient.createIRC(session, **kwargs) session.client = client if config.irc["webirc_mode"] == "": proceed(None) else: notice = lambda x: session.event(connect_notice(x)) notice("Looking up your hostname...") def callback(hostname): notice("Found your hostname.") proceed(hostname) def errback(failure): notice("Couldn't look up your hostname!") proceed(ip) qdns.lookupAndVerifyPTR(ip, timeout=[config.tuneback["dns_timeout"]]).addCallbacks(callback, errback) Sessions[id] = session return id