Beispiel #1
0
 def __init__(self, CFxHandle, paramDict, ModuleName):
     ControllerModule.__init__(self, CFxHandle, paramDict, ModuleName)
     self.ipop_xmpp_details = {}
     self.keyring_installed = False
     # Check whether the KeyRing Module has been installed
     try:
         import keyring
         self.keyring_installed = True
     except:
         self.registerCBT("Logger", "warning",
                          "Key-ring module not installed.")
Beispiel #2
0
 def __init__(self,CFxHandle,paramDict,ModuleName):
     ControllerModule.__init__(self,CFxHandle,paramDict,ModuleName)
     self.xmpp_peers = defaultdict(int)
     # need to maintain uid<->jid mapping to route xmpp messages.
     self.uid_jid = {}
     self.jid_uid = defaultdict(lambda:['',False])
     self.xmpp_username = self.CMConfig.get("username")
     self.xmpp_passwd = self.CMConfig.get("password")
     self.xmpp_host = self.CMConfig.get("xmpp_host")
     self.uid = ""
     # time of last recvd xmpp advt.
     self.last_sent_advt = 0
     # keeps track of if xmpp advt recvd in interval
     self.xmpp_advt_recvd = True
     # Initial ADVT Delay
     self.INITIAL_ADVT_DELAY =5
     # interval between sending advertisements
     self.advt_delay = self.INITIAL_ADVT_DELAY
     # Maximum delay between advertisements is 10 minutes
     self.MAX_ADVT_DELAY = 600 
     # initialize the base Xmpp client class
     sleekxmpp.ClientXMPP.__init__(self,self.xmpp_username,self.xmpp_passwd,sasl_mech='PLAIN')
     self['feature_mechanisms'].unencrypted_plain = True
     # register a new plugin stanza and handler for it,
     # whenever a matching message will be received on 
     # the xmpp stream , registered handler will be called.
     register_stanza_plugin(Message, Ipop_Msg)
     self.registerHandler(
             Callback('Ipop',
             StanzaPath('message/Ipop'),
             self.MsgListener))
     # Register event handler for session start 
     self.add_event_handler("session_start",self.start)
     # calculate UID, for the meantime
     # address mapping
     self.uid_ip4_table = {}
     self.ip4_uid_table = {}
     # populate uid_ip4_table and ip4_uid_table with all UID and IPv4
     # mappings within the /16 subnet
     parts = self.CMConfig["ip4"].split(".")
     ip_prefix = parts[0] + "." + parts[1] + "."
     for i in range(0, 255):
         for j in range(0, 255):
             ip4 = ip_prefix + str(i) + "." + str(j)
             uid = fxlib.gen_uid(ip4)
             self.uid_ip4_table[uid] = ip4
             self.ip4_uid_table[ip4] = uid
     self.uid = self.ip4_uid_table[self.CMConfig["ip4"]]
     # Start xmpp handling thread
     self.xmpp_handler()
 def __init__(self,CFxHandle,paramDict,ModuleName):
     ControllerModule.__init__(self,CFxHandle,paramDict,ModuleName)
     self.xmpp_peers = defaultdict(int)
     # need to maintain uid<->jid mapping to route xmpp messages.
     self.uid_jid = {}
     self.xmpp_username = self.CMConfig.get("username")
     self.xmpp_passwd = self.CMConfig.get("password")
     self.xmpp_host = self.CMConfig.get("xmpp_host")
     self.uid = ""
     # initialize the base Xmpp client class
     sleekxmpp.ClientXMPP.__init__(self,self.xmpp_username,self.xmpp_passwd)
     # register a new plugin stanza and handler for it,
     # whenever a matching message will be received on 
     # the xmpp stream , registered handler will be called.
     register_stanza_plugin(Message, Ipop_Msg)
     self.registerHandler(
             Callback('Ipop',
             StanzaPath('message/Ipop'),
             self.MsgListener))
     # Register event handler for session start 
     self.add_event_handler("session_start",self.start)
     # calculate UID, for the meantime
     # address mapping
     self.uid_ip4_table = {}
     self.ip4_uid_table = {}
     # populate uid_ip4_table and ip4_uid_table with all UID and IPv4
     # mappings within the /16 subnet
     parts = self.CMConfig["ip4"].split(".")
     ip_prefix = parts[0] + "." + parts[1] + "."
     for i in range(0, 255):
         for j in range(0, 255):
             ip4 = ip_prefix + str(i) + "." + str(j)
             uid = fxlib.gen_uid(ip4)
             self.uid_ip4_table[uid] = ip4
             self.ip4_uid_table[ip4] = uid
     self.uid = self.ip4_uid_table[self.CMConfig["ip4"]]
     # Start xmpp handling thread
     self.xmpp_handler()
Beispiel #4
0
 def __init__(self, CFxHandle, paramDict, ModuleName):
     ControllerModule.__init__(self, CFxHandle, paramDict, ModuleName)
     self.xmpp_peers = defaultdict(int)
     # need to maintain uid<->jid mapping to route xmpp messages.
     self.uid_jid = {}
     self.xmpp_username = self.CMConfig.get("username")
     self.xmpp_passwd = self.CMConfig.get("password")
     self.xmpp_host = self.CMConfig.get("xmpp_host")
     self.uid = ""
     # initialize the base Xmpp client class
     sleekxmpp.ClientXMPP.__init__(self, self.xmpp_username,
                                   self.xmpp_passwd)
     # register a new plugin stanza and handler for it,
     # whenever a matching message will be received on
     # the xmpp stream , registered handler will be called.
     register_stanza_plugin(Message, Ipop_Msg)
     self.registerHandler(
         Callback('Ipop', StanzaPath('message/Ipop'), self.MsgListener))
     # Register event handler for session start
     self.add_event_handler("session_start", self.start)
     # calculate UID, for the meantime
     # address mapping
     self.uid_ip4_table = {}
     self.ip4_uid_table = {}
     # populate uid_ip4_table and ip4_uid_table with all UID and IPv4
     # mappings within the /16 subnet
     parts = self.CMConfig["ip4"].split(".")
     ip_prefix = parts[0] + "." + parts[1] + "."
     for i in range(0, 255):
         for j in range(0, 255):
             ip4 = ip_prefix + str(i) + "." + str(j)
             uid = fxlib.gen_uid(ip4)
             self.uid_ip4_table[uid] = ip4
             self.ip4_uid_table[ip4] = uid
     self.uid = self.ip4_uid_table[self.CMConfig["ip4"]]
     # Start xmpp handling thread
     self.xmpp_handler()
Beispiel #5
0
    def __init__(self, CFxHandle, paramDict, ModuleName):
        ControllerModule.__init__(self, CFxHandle, paramDict, ModuleName)
        # keeps track of last recvd advertisement and if node is active on XMPP.
        self.xmpp_peers = defaultdict(lambda: [0, False])
        # need to maintain uid<->jid mapping to route xmpp messages.
        self.uid_jid = {}
        # FullJID,Knows my UID,num(Correct advts recvd)
        self.jid_uid = defaultdict(lambda: ['', False, 1])
        self.xmpp_username = self.CMConfig.get("Username")
        self.xmpp_passwd = self.CMConfig.get("Password", "None")
        self.xmpp_host = self.CMConfig.get("AddressHost")
        self.xmpp_port = self.CMConfig.get("Port")
        self.vpn_type = self.CFxHandle.queryParam("CFx", "Model")
        self.interface_name = self.CMConfig.get("TapName")
        self.uid = ""
        self.update_peerlist = False
        # time of last recvd xmpp advt.
        self.last_sent_advt = 0
        # keeps track of if xmpp advt recvd in interval
        self.xmpp_advt_recvd = True
        # Initial ADVT Delay
        self.INITIAL_ADVT_DELAY = 5
        # interval between sending advertisements
        self.advt_delay = self.INITIAL_ADVT_DELAY
        # Maximum delay between advertisements is 10 minutes
        self.MAX_ADVT_DELAY = 600
        # initialize the base Xmpp client class, handle login/authentication.
        if self.CMConfig.get("AuthenticationMethod") == "x509" and \
                (self.xmpp_username != None \
                         or self.xmpp_passwd != None):
            raise RuntimeError(
                "x509 Authentication Error: Username/Password in IPOP configuration file."
            )

        use_tls = True
        if self.CMConfig.get("AuthenticationMethod") == "x509":
            sleekxmpp.ClientXMPP.__init__(self,
                                          self.xmpp_host,
                                          self.xmpp_passwd,
                                          sasl_mech='EXTERNAL')
            self.ssl_version = ssl.PROTOCOL_TLSv1
            self.ca_certs = self.CMConfig.get("TrustStore")
            self.certfile = self.CMConfig.get(
                "CertDirectory") + self.CMConfig.get("CertFile")
            self.keyfile = self.CMConfig.get(
                "CertDirectory") + self.CMConfig.get("Keyfile")
        else:
            sleekxmpp.ClientXMPP.__init__(self,
                                          self.xmpp_username,
                                          self.xmpp_passwd,
                                          sasl_mech='PLAIN')
            if self.CMConfig.get("AcceptUntrustedServer") == True:
                self['feature_mechanisms'].unencrypted_plain = True
                use_tls = False
            else:
                self.ca_certs = self.CMConfig.get("TrustStore")

        # register a new plugin stanza and handler for it,
        # whenever a matching message will be received on
        # the xmpp stream , registered handler will be called.
        register_stanza_plugin(Message, Ipop_Msg)
        self.registerHandler(
            Callback('Ipop', StanzaPath('message/Ipop'), self.MsgListener))

        # Register event handler for session start
        self.add_event_handler("session_start", self.start)

        self.add_event_handler("roster_update", self.deletepeerjid)

        # populate uid_ip4_table and ip4_uid_table with all UID and IPv4
        # mappings within the /16 subnet

        if (self.vpn_type == "GroupVPN"):
            ipop_interfaces = self.CFxHandle.queryParam("Tincan", "Vnets")
            for interface_details in ipop_interfaces:
                if interface_details["TapName"] == self.interface_name:
                    self.uid = interface_details["uid"]
        elif (self.vpn_type == "SocialVPN"):
            self.registerCBT('Watchdog', 'QUERY_IPOP_STATE')
        # Start xmpp handling thread
        self.xmpp_handler()
Beispiel #6
0
 def __init__(self, CFxHandle, paramDict, ModuleName):
     ControllerModule.__init__(self, CFxHandle, paramDict, ModuleName)
     self.presence_publisher = None
     self.ipop_xmpp_details = {}
     self.keyring_installed = False
Beispiel #7
0
 def __init__(self, CFxHandle, paramDict, ModuleName):
     ControllerModule.__init__(self, CFxHandle, paramDict, ModuleName)
     self.presence_publisher = None
     self.ipop_xmpp_details = {}
     self.keyring_installed = False
Beispiel #8
0
    def __init__(self,CFxHandle,paramDict,ModuleName):
        ControllerModule.__init__(self,CFxHandle,paramDict,ModuleName)
        # keeps track of last recvd advertisement and if node is active on XMPP.
        self.xmpp_peers = defaultdict(lambda:[0,False])
        # need to maintain uid<->jid mapping to route xmpp messages.
        self.uid_jid = {}
        # FullJID,Knows my UID,num(Correct advts recvd)
        self.jid_uid = defaultdict(lambda:['',False,1])
        self.xmpp_username = self.CMConfig.get("xmpp_username")
        self.xmpp_passwd = self.CMConfig.get("xmpp_password")
        self.xmpp_host = self.CMConfig.get("xmpp_host")
        self.xmpp_port = self.CMConfig.get("xmpp_port")
        self.vpn_type = self.CFxHandle.queryParam("vpn_type")
        self.uid = ""
        # time of last recvd xmpp advt.
        self.last_sent_advt = 0
        # keeps track of if xmpp advt recvd in interval
        self.xmpp_advt_recvd = True
        # Initial ADVT Delay
        self.INITIAL_ADVT_DELAY =5
        # interval between sending advertisements
        self.advt_delay = self.INITIAL_ADVT_DELAY
        # Maximum delay between advertisements is 10 minutes
        self.MAX_ADVT_DELAY = 600 
        # initialize the base Xmpp client class, handle login/authentication.
        if self.CMConfig.get("xmpp_authentication_method")=="x509" and \
            (self.CMConfig.get("xmpp_username")!= None \
                or self.CMConfig.get("xmpp_password")!= None):
            raise RuntimeError("x509 Authentication Exception. Username or Password present in IPOP configuration file.")

        use_tls = True
        if self.CMConfig.get("xmpp_authentication_method")=="x509":
            sleekxmpp.ClientXMPP.__init__(self,self.xmpp_host,self.xmpp_passwd,sasl_mech='EXTERNAL')
            self.ssl_version = ssl.PROTOCOL_TLSv1
            self.ca_certs = self.CMConfig.get("truststore")
            self.certfile = self.CMConfig.get("certdirectory")+self.CMConfig.get("certfile")
            self.keyfile = self.CMConfig.get("certdirectory")+self.CMConfig.get("keyfile")
        else:
            sleekxmpp.ClientXMPP.__init__(self, self.xmpp_username, self.xmpp_passwd, sasl_mech='PLAIN')
            if self.CMConfig.get("xmpp_accept_untrusted_server")==True:
                self['feature_mechanisms'].unencrypted_plain = True
                use_tls = False
            else:
                self.ca_certs = self.CMConfig.get("truststore")
        # register a new plugin stanza and handler for it,
        # whenever a matching message will be received on 
        # the xmpp stream , registered handler will be called.
        register_stanza_plugin(Message, Ipop_Msg)
        self.registerHandler(
                Callback('Ipop',
                StanzaPath('message/Ipop'),
                self.MsgListener))
        # Register event handler for session start 
        self.add_event_handler("session_start",self.start)
        # calculate UID, for the meantime
        # address mapping
        self.uid_ip4_table = {}
        self.ip4_uid_table = {}
        # populate uid_ip4_table and ip4_uid_table with all UID and IPv4
        # mappings within the /16 subnet
        if (self.vpn_type == "GroupVPN"):
            parts = self.CFxHandle.queryParam("ip4").split(".")
            ip_prefix = parts[0] + "." + parts[1] + "."
            for i in range(0, 255):
                for j in range(0, 255):
                    ip4 = ip_prefix + str(i) + "." + str(j)
                    uid = fxlib.gen_uid(ip4)
                    self.uid_ip4_table[uid] = ip4
                    self.ip4_uid_table[ip4] = uid
            self.uid = self.ip4_uid_table[self.CFxHandle.queryParam("ip4")]
        elif (self.vpn_type == "SocialVPN"):
            self.registerCBT('Watchdog', 'QUERY_IPOP_STATE')
        # Start xmpp handling thread
        self.xmpp_handler()