def do_incoming_auth(event, message):
    global is_authed, connected_protoctl
    if (message.command == "PROTOCTL"):
        connected_protoctl = message
    elif (message.command == "PASS"):
        if (message.parameters[0] != config.get("Network/Password")):
            log.critical("Password mismatch!  Expected '%s', got '%s'",
                         config.get("Network/Password"), message.parameters[0])
            Network.sendMsg(
                IRCMessage(':', config.get("Server/Name"), "ERROR",
                           "Closing link: password mismatch"))
            #Network.disconnect() #this is done in the main file
            ffservices.shutdown(1)
    elif (message.command == "SERVER"):
        if (is_authed): return
        is_authed = True
        Server.addServer(
            Server.createServerFromMessage(message, connected_protoctl))
        Event.trigger("Network/LinkEstablished")
        Network.isAuthed = True
        #anything that watches for this event should do things like send user info (NICK),
        #channel membership, channel info, modes, etc at this point
        Network.sendMsg(
            IRCMessage(None, None, "netinfo", 0, int(time.time()),
                       ffservices.unrealProtocol, "*", 0, 0, 0,
                       config.get("Network/Name")))
        #TODO: keep track of my max known global users?
        Network.sendMsg(IRCMessage(None, None, "eos"))
        event.stop()
Esempio n. 2
0
def disconnect():
    global svr_sock, isConnected, isAuthed
    isConnected = False
    isAuthed = False
    Event.trigger("Network/Disconnect")
    if (svr_sock is None): return True
    svr_sock.close()
    return True
Esempio n. 3
0
def disconnect():
	global svr_sock, isConnected, isAuthed
	isConnected=False
	isAuthed=False
	Event.trigger("Network/Disconnect")
	if(svr_sock is None): return True
	svr_sock.close()
	return True
Esempio n. 4
0
def connect():
	global svr_sock, isConnected
	try:
		svr_sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		svr_sock.connect((config.get("Network/Server"), config.get("Network/Port")))
		isConnected=True
	except Exception as e:
		log.error("Failure to connect to server: %s:%d : %s", config.get("Network/Server"), config.get("Network/Port"), str(e))
		return False
	
	Event.trigger("Network/Connect")
	return True
Esempio n. 5
0
def connect():
    global svr_sock, isConnected
    try:
        svr_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        svr_sock.connect(
            (config.get("Network/Server"), config.get("Network/Port")))
        isConnected = True
    except Exception as e:
        log.error("Failure to connect to server: %s:%d : %s",
                  config.get("Network/Server"), config.get("Network/Port"),
                  str(e))
        return False

    Event.trigger("Network/Connect")
    return True
def do_incoming_auth(event, message):
	global is_authed, connected_protoctl
	if(message.command=="PROTOCTL"):
		connected_protoctl=message
	elif(message.command=="PASS"):
		if(message.parameters[0]!=config.get("Network/Password")):
			log.critical("Password mismatch!  Expected '%s', got '%s'", config.get("Network/Password"), message.parameters[0])
			Network.sendMsg(IRCMessage(':', config.get("Server/Name"), "ERROR", "Closing link: password mismatch"))
			#Network.disconnect() #this is done in the main file
			ffservices.shutdown(1)
	elif(message.command=="SERVER"):
		if(is_authed): return
		is_authed=True
		Server.addServer(Server.createServerFromMessage(message, connected_protoctl))
		Event.trigger("Network/LinkEstablished")
		Network.isAuthed=True
		#anything that watches for this event should do things like send user info (NICK),
		#channel membership, channel info, modes, etc at this point
		Network.sendMsg(IRCMessage(None, None, "netinfo", 0, int(time.time()), ffservices.unrealProtocol, "*", 0, 0, 0, config.get("Network/Name")))
		#TODO: keep track of my max known global users?
		Network.sendMsg(IRCMessage(None, None, "eos"))
		event.stop()
Esempio n. 7
0
def sendMsg(msg):
    global svr_sock
    Event.trigger("Message/Outgoing/" + msg.command, message=msg)
    return svr_sock.send(str(msg))
Esempio n. 8
0
def sendMsg(msg):
	global svr_sock
	Event.trigger("Message/Outgoing/"+msg.command, message=msg)
	return svr_sock.send(str(msg))