Beispiel #1
0
    def get_wifi_connection_info(self,
                                 root_node,
                                 default=False,
                                 prototype=False,
                                 force_readonly=False):
        conn = {}

        if prototype:
            conn['name'] = ''
        else:
            conn['name'] = root_node.find('name').text.strip()

        conn['deviceType'] = DEVICE_WLAN
        conn['default'] = default
        conn['origin'] = 'xml'

        conn['editable'] = True
        if force_readonly:
            conn['editable'] = False
        elif root_node.attrib.has_key('readonly'):
            conn['editable'] = root_node.attrib['readonly'] == '0'

        conn['profiles'] = []
        profile_nodes = root_node.findall('profile')
        for profile_node in profile_nodes:
            profile = {}
            if profile_node.attrib.has_key('condition'):
                profile['condition'] = profile_node.attrib['condition']
            else:
                profile['condition'] = False

            # Unused, but just for the record
            #
            # AUT802_1X{
            #   AUT802_1X_NINGUNA = 0,
            #   AUT802_1X_EAP_MD5 = 4,
            #   AUT802_1X_EAP_SIM = 18,
            #   AUT802_1X_EAP_PEAP = 25,
            #   AUT802_1X_EAP_MSCHAPV2 = 26,
            #   AUT802_1X_EAP_WISPR = 100,
            #   AUT802_1X_EAP_THE_CLOUD = 105,
            #   AUT802_1X_EAP_LANDING_PAGE = 1000,
            # };
            fields = (('', 'ssid', ''), \
                ('', 'mac', '0.0.0.0.0.0'), \
                ('', 'encryption', 0), \
                ('', 'authentication', 0), \
                ('', 'network-password', ''), \
                ('', 'hidden', False), \
                ('auth-802-1x', 'type', '0'), \
                ('auth-802-1x', 'user', ''), \
                ('auth-802-1x', 'password', ''))
            profile = self.__import_block(profile_node, fields)
            profile['password'] = decode_password(profile['network-password'])
            conn['profiles'].append(profile)

            return conn
Beispiel #2
0
    def get_wifi_connection_info(self, root_node, default=False, prototype=False, force_readonly=False):
        conn = {}

        if prototype:
            conn['name'] = ''
        else:
            conn['name'] = root_node.find('name').text.strip()

        conn['deviceType'] = DEVICE_WLAN
        conn['default'] = default
        conn['origin'] = 'xml'

        conn['editable'] = True
        if force_readonly:
            conn['editable'] = False
        elif root_node.attrib.has_key('readonly'):
            conn['editable'] = root_node.attrib['readonly'] == '0'

        conn['profiles'] = []
        profile_nodes = root_node.findall('profile')
        for profile_node in profile_nodes:
            profile = {}
            if profile_node.attrib.has_key('condition'):
                profile['condition'] = profile_node.attrib['condition']
            else:
                profile['condition'] = False

            # Unused, but just for the record
            #
            # AUT802_1X{
            #   AUT802_1X_NINGUNA = 0,
            #   AUT802_1X_EAP_MD5 = 4,
            #   AUT802_1X_EAP_SIM = 18,
            #   AUT802_1X_EAP_PEAP = 25,
            #   AUT802_1X_EAP_MSCHAPV2 = 26,
            #   AUT802_1X_EAP_WISPR = 100,
            #   AUT802_1X_EAP_THE_CLOUD = 105,
            #   AUT802_1X_EAP_LANDING_PAGE = 1000,
            # };
            fields = (('', 'ssid', ''), \
                ('', 'mac', '0.0.0.0.0.0'), \
                ('', 'encryption', 0), \
                ('', 'authentication', 0), \
                ('', 'network-password', ''), \
                ('', 'hidden', False), \
                ('auth-802-1x', 'type', '0'), \
                ('auth-802-1x', 'user', ''), \
                ('auth-802-1x', 'password', ''))
            profile = self.__import_block(profile_node, fields)
            profile['password'] = decode_password(profile['network-password'])
            conn['profiles'].append(profile)

            return conn
Beispiel #3
0
    def get_wwan_connection_info (self, root_node, default=False, wwan_prototype=False, force_readonly=False):
        conn = {}

        if wwan_prototype == True :
            conn['name'] = ""
        else:
            conn['name'] = root_node.find('name').text.strip()

        conn['deviceType'] = DEVICE_MODEM
        conn['default'] = default
        conn['origin']='xml'
        if force_readonly:
            conn['editable'] = False
        else:
            if root_node.attrib.has_key('readonly'):
                if root_node.attrib['readonly'] == '0':
                    conn['editable'] = True
                else:
                    conn['editable'] = False
            else:
                conn['editable'] = True

        conn['profiles'] = []
        profile_nodes = root_node.findall('profile')
        for profile_node in profile_nodes:
            profile = {}
            if profile_node.attrib.has_key('condition'):
                profile['condition'] = profile_node.attrib['condition']
            else:
                profile['condition'] = False

            try:
                profile['username'] = profile_node.find('auth-info/username').text.strip()
                if profile['username'] == None:
                    profile['username'] = ''
            except:
                profile['username'] = ''

            try:
                coded_password = profile_node.find('auth-info/password').text.strip()
                if coded_password is None:
                    profile['password'] = ''
                else:
                    profile['password'] = decode_password(coded_password)
            except:
                profile['password'] = ''

            profile['ask_password'] = int(profile_node.find('auth-info/ask-password').text) == 1
            profile['cypher_password'] = int(profile_node.find('auth-info/cypher-password').text) == 1

            profile['auto_dns'] = int(profile_node.find('dns-info/manual-dns-server').text) == 0
            dns_servers = []
            nodes = profile_node.findall('dns-info/dns-server-list/dns-server')
            for node in nodes:
                node_str=node.text;
                if (node_str!=None):
                    dns_servers = dns_servers + [node.text.strip()]


            profile['dns_servers'] = dns_servers

            profile['domain_active'] = int(profile_node.find('dns-info/dns-suffixes/active').text) == 1
            if profile['domain_active']:
                try:
                    profile['domains'] = [suffix.strip() for suffix in profile_node.find('dns-info/dns-suffixes/suffixes').text.split(';')]
                except:
                    profile['domains'] = []

            proxy_tag=profile_node.find('proxy-info/configuration')
            if proxy_tag!=None:
                proxyVal=profile_node.find('proxy-info/configuration').text.strip()
                try:
                    profile['proxy'] = int(proxyVal)
                except ValueError:
                    profile['proxy'] = 0;

                profile['proxy_ip'] = ""
                profile['proxy_port'] = 0
                profile['proxy_https_ip'] = ""
                profile['proxy_https_port'] = 0
                profile['proxy_socks_ip'] = ""
                profile['proxy_socks_port'] = 0
                profile['proxy_ftp_ip'] = ""
                profile['proxy_ftp_port'] = 0
                profile['proxy_same_proxy'] = False
                profile['proxy_ignore'] = []

                if profile['proxy']:
                    proxies = profile_node.findall('proxy-info/proxy-list/proxy')
                    for proxy in proxies:
                        if proxy.attrib.has_key('type') and proxy.attrib['type'] == 'any':
                            proxy_data = [substring.strip() for substring in proxy.text.split(':')]
                            profile['proxy_ip'] = proxy_data[0]
                            profile['proxy_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = True
                            break
                        if proxy.attrib.has_key('type') and proxy.attrib['type'] == 'http':
                            proxy_data = [substring.strip() for substring in proxy.text.split(':')]
                            profile['proxy_ip'] = proxy_data[0]
                            profile['proxy_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key('type') and proxy.attrib['type'] == 'https':
                            proxy_data = [substring.strip() for substring in proxy.text.split(':')]
                            profile['proxy_https_ip'] = proxy_data[0]
                            profile['proxy_https_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key('type') and proxy.attrib['type'] == 'socks':
                            proxy_data = [substring.strip() for substring in proxy.text.split(':')]
                            profile['proxy_socks_ip'] = proxy_data[0]
                            profile['proxy_socks_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key('type') and proxy.attrib['type'] == 'ftp':
                            proxy_data = [substring.strip() for substring in proxy.text.split(':')]
                            profile['proxy_ftp_ip'] = proxy_data[0]
                            profile['proxy_ftp_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False

                    bypass_proxies = profile_node.findall('proxy-info/bypass-proxy/bypass-addresses')
                    if bypass_proxies != None and len(bypass_proxies)>0:
                        if (bypass_proxies[0].text!=None):
                            profile['proxy_ignore']=bypass_proxies[0].text.rsplit(';')

            else:
                profile['proxy'] = 0

            try:
                profile['apn'] = profile_node.find('apn').text.strip()
                if profile['apn'] == None :
                    profile['apn'] = ''
            except:
                profile['apn'] = ''

            profile['ip_info_active'] = int(profile_node.find('ip-info/active').text) == 1
            ip_info_address=profile_node.find('ip-info/address').text
            if (ip_info_address!=None):
                profile['ip_info_address'] = ip_info_address.strip()
            else:
                profile['ip_info_address']=''

            conn['profiles'] = conn['profiles'] + [profile]

        return conn
Beispiel #4
0
    def get_wwan_connection_info(self,
                                 root_node,
                                 default=False,
                                 wwan_prototype=False,
                                 force_readonly=False):
        conn = {}

        if wwan_prototype == True:
            conn['name'] = ""
        else:
            conn['name'] = root_node.find('name').text.strip()

        conn['deviceType'] = DEVICE_MODEM
        conn['default'] = default
        conn['origin'] = 'xml'
        if force_readonly:
            conn['editable'] = False
        else:
            if root_node.attrib.has_key('readonly'):
                if root_node.attrib['readonly'] == '0':
                    conn['editable'] = True
                else:
                    conn['editable'] = False
            else:
                conn['editable'] = True

        conn['profiles'] = []
        profile_nodes = root_node.findall('profile')
        for profile_node in profile_nodes:
            profile = {}
            if profile_node.attrib.has_key('condition'):
                profile['condition'] = profile_node.attrib['condition']
            else:
                profile['condition'] = False

            try:
                profile['username'] = profile_node.find(
                    'auth-info/username').text.strip()
                if profile['username'] == None:
                    profile['username'] = ''
            except:
                profile['username'] = ''

            try:
                coded_password = profile_node.find(
                    'auth-info/password').text.strip()
                if coded_password is None:
                    profile['password'] = ''
                else:
                    profile['password'] = decode_password(coded_password)
            except:
                profile['password'] = ''

            profile['ask_password'] = int(
                profile_node.find('auth-info/ask-password').text) == 1
            profile['cypher_password'] = int(
                profile_node.find('auth-info/cypher-password').text) == 1

            profile['auto_dns'] = int(
                profile_node.find('dns-info/manual-dns-server').text) == 0
            dns_servers = []
            nodes = profile_node.findall('dns-info/dns-server-list/dns-server')
            for node in nodes:
                node_str = node.text
                if (node_str != None):
                    dns_servers = dns_servers + [node.text.strip()]

            profile['dns_servers'] = dns_servers

            profile['domain_active'] = int(
                profile_node.find('dns-info/dns-suffixes/active').text) == 1
            if profile['domain_active']:
                try:
                    profile['domains'] = [
                        suffix.strip() for suffix in profile_node.find(
                            'dns-info/dns-suffixes/suffixes').text.split(';')
                    ]
                except:
                    profile['domains'] = []

            proxy_tag = profile_node.find('proxy-info/configuration')
            if proxy_tag != None:
                proxyVal = profile_node.find(
                    'proxy-info/configuration').text.strip()
                try:
                    profile['proxy'] = int(proxyVal)
                except ValueError:
                    profile['proxy'] = 0

                profile['proxy_ip'] = ""
                profile['proxy_port'] = 0
                profile['proxy_https_ip'] = ""
                profile['proxy_https_port'] = 0
                profile['proxy_socks_ip'] = ""
                profile['proxy_socks_port'] = 0
                profile['proxy_ftp_ip'] = ""
                profile['proxy_ftp_port'] = 0
                profile['proxy_same_proxy'] = False
                profile['proxy_ignore'] = []

                if profile['proxy']:
                    proxies = profile_node.findall(
                        'proxy-info/proxy-list/proxy')
                    for proxy in proxies:
                        if proxy.attrib.has_key(
                                'type') and proxy.attrib['type'] == 'any':
                            proxy_data = [
                                substring.strip()
                                for substring in proxy.text.split(':')
                            ]
                            profile['proxy_ip'] = proxy_data[0]
                            profile['proxy_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = True
                            break
                        if proxy.attrib.has_key(
                                'type') and proxy.attrib['type'] == 'http':
                            proxy_data = [
                                substring.strip()
                                for substring in proxy.text.split(':')
                            ]
                            profile['proxy_ip'] = proxy_data[0]
                            profile['proxy_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key(
                                'type') and proxy.attrib['type'] == 'https':
                            proxy_data = [
                                substring.strip()
                                for substring in proxy.text.split(':')
                            ]
                            profile['proxy_https_ip'] = proxy_data[0]
                            profile['proxy_https_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key(
                                'type') and proxy.attrib['type'] == 'socks':
                            proxy_data = [
                                substring.strip()
                                for substring in proxy.text.split(':')
                            ]
                            profile['proxy_socks_ip'] = proxy_data[0]
                            profile['proxy_socks_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False
                        if proxy.attrib.has_key(
                                'type') and proxy.attrib['type'] == 'ftp':
                            proxy_data = [
                                substring.strip()
                                for substring in proxy.text.split(':')
                            ]
                            profile['proxy_ftp_ip'] = proxy_data[0]
                            profile['proxy_ftp_port'] = int(proxy_data[1])
                            profile['proxy_same_proxy'] = False

                    bypass_proxies = profile_node.findall(
                        'proxy-info/bypass-proxy/bypass-addresses')
                    if bypass_proxies != None and len(bypass_proxies) > 0:
                        if (bypass_proxies[0].text != None):
                            profile['proxy_ignore'] = bypass_proxies[
                                0].text.rsplit(';')

            else:
                profile['proxy'] = 0

            try:
                profile['apn'] = profile_node.find('apn').text.strip()
                if profile['apn'] == None:
                    profile['apn'] = ''
            except:
                profile['apn'] = ''

            profile['ip_info_active'] = int(
                profile_node.find('ip-info/active').text) == 1
            ip_info_address = profile_node.find('ip-info/address').text
            if (ip_info_address != None):
                profile['ip_info_address'] = ip_info_address.strip()
            else:
                profile['ip_info_address'] = ''

            conn['profiles'] = conn['profiles'] + [profile]

        return conn