GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 173.249.157.85  /  Your IP : 18.191.175.60
Web Server : Apache
System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User : econtech ( 1005)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python2.7/site-packages/cloudinit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python2.7/site-packages/cloudinit/netinfo.py
# Copyright (C) 2012 Canonical Ltd.
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
# Copyright (C) 2012 Yahoo! Inc.
#
# Author: Scott Moser <scott.moser@canonical.com>
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
#
# This file is part of cloud-init. See LICENSE file for license information.

from copy import copy, deepcopy
import re

from cloudinit import log as logging
from cloudinit.net.network_state import net_prefix_to_ipv4_mask
from cloudinit import util

from cloudinit.simpletable import SimpleTable

LOG = logging.getLogger()


DEFAULT_NETDEV_INFO = {
    "ipv4": [],
    "ipv6": [],
    "hwaddr": "",
    "up": False
}


def _netdev_info_iproute(ipaddr_out):
    """
    Get network device dicts from ip route and ip link info.

    @param ipaddr_out: Output string from 'ip addr show' command.

    @returns: A dict of device info keyed by network device name containing
              device configuration values.
    @raise: TypeError if ipaddr_out isn't a string.
    """
    devs = {}
    dev_name = None
    for num, line in enumerate(ipaddr_out.splitlines()):
        m = re.match(r'^\d+:\s(?P<dev>[^:]+):\s+<(?P<flags>\S+)>\s+.*', line)
        if m:
            dev_name = m.group('dev').lower().split('@')[0]
            flags = m.group('flags').split(',')
            devs[dev_name] = {
                'ipv4': [], 'ipv6': [], 'hwaddr': '',
                'up': bool('UP' in flags and 'LOWER_UP' in flags),
            }
        elif 'inet6' in line:
            m = re.match(
                r'\s+inet6\s(?P<ip>\S+)\sscope\s(?P<scope6>\S+).*', line)
            if not m:
                LOG.warning(
                    'Could not parse ip addr show: (line:%d) %s', num, line)
                continue
            devs[dev_name]['ipv6'].append(m.groupdict())
        elif 'inet' in line:
            m = re.match(
                r'\s+inet\s(?P<cidr4>\S+)(\sbrd\s(?P<bcast>\S+))?\sscope\s'
                r'(?P<scope>\S+).*', line)
            if not m:
                LOG.warning(
                    'Could not parse ip addr show: (line:%d) %s', num, line)
                continue
            match = m.groupdict()
            cidr4 = match.pop('cidr4')
            addr, _, prefix = cidr4.partition('/')
            if not prefix:
                prefix = '32'
            devs[dev_name]['ipv4'].append({
                'ip': addr,
                'bcast': match['bcast'] if match['bcast'] else '',
                'mask': net_prefix_to_ipv4_mask(prefix),
                'scope': match['scope']})
        elif 'link' in line:
            m = re.match(
                r'\s+link/(?P<link_type>\S+)\s(?P<hwaddr>\S+).*', line)
            if not m:
                LOG.warning(
                    'Could not parse ip addr show: (line:%d) %s', num, line)
                continue
            if m.group('link_type') == 'ether':
                devs[dev_name]['hwaddr'] = m.group('hwaddr')
            else:
                devs[dev_name]['hwaddr'] = ''
        else:
            continue
    return devs


def _netdev_info_ifconfig(ifconfig_data):
    # fields that need to be returned in devs for each dev
    devs = {}
    for line in ifconfig_data.splitlines():
        if len(line) == 0:
            continue
        if line[0] not in ("\t", " "):
            curdev = line.split()[0]
            # current ifconfig pops a ':' on the end of the device
            if curdev.endswith(':'):
                curdev = curdev[:-1]
            if curdev not in devs:
                devs[curdev] = deepcopy(DEFAULT_NETDEV_INFO)
        toks = line.lower().strip().split()
        if toks[0] == "up":
            devs[curdev]['up'] = True
        # If the output of ifconfig doesn't contain the required info in the
        # obvious place, use a regex filter to be sure.
        elif len(toks) > 1:
            if re.search(r"flags=\d+<up,", toks[1]):
                devs[curdev]['up'] = True

        for i in range(len(toks)):
            if toks[i] == "inet":  # Create new ipv4 addr entry
                devs[curdev]['ipv4'].append(
                    {'ip': toks[i + 1].lstrip("addr:")})
            elif toks[i].startswith("bcast:"):
                devs[curdev]['ipv4'][-1]['bcast'] = toks[i].lstrip("bcast:")
            elif toks[i] == "broadcast":
                devs[curdev]['ipv4'][-1]['bcast'] = toks[i + 1]
            elif toks[i].startswith("mask:"):
                devs[curdev]['ipv4'][-1]['mask'] = toks[i].lstrip("mask:")
            elif toks[i] == "netmask":
                devs[curdev]['ipv4'][-1]['mask'] = toks[i + 1]
            elif toks[i] == "hwaddr" or toks[i] == "ether":
                devs[curdev]['hwaddr'] = toks[i + 1]
            elif toks[i] == "inet6":
                if toks[i + 1] == "addr:":
                    devs[curdev]['ipv6'].append({'ip': toks[i + 2]})
                else:
                    devs[curdev]['ipv6'].append({'ip': toks[i + 1]})
            elif toks[i] == "prefixlen":  # Add prefix to current ipv6 value
                addr6 = devs[curdev]['ipv6'][-1]['ip'] + "/" + toks[i + 1]
                devs[curdev]['ipv6'][-1]['ip'] = addr6
            elif toks[i].startswith("scope:"):
                devs[curdev]['ipv6'][-1]['scope6'] = toks[i].lstrip("scope:")
            elif toks[i] == "scopeid":
                res = re.match(r'.*<(\S+)>', toks[i + 1])
                if res:
                    devs[curdev]['ipv6'][-1]['scope6'] = res.group(1)
                else:
                    devs[curdev]['ipv6'][-1]['scope6'] = toks[i + 1]

    return devs


def netdev_info(empty=""):
    devs = {}
    if util.which('ip'):
        # Try iproute first of all
        (ipaddr_out, _err) = util.subp(["ip", "addr", "show"])
        devs = _netdev_info_iproute(ipaddr_out)
    elif util.which('ifconfig'):
        # Fall back to net-tools if iproute2 is not present
        (ifcfg_out, _err) = util.subp(["ifconfig", "-a"], rcs=[0, 1])
        devs = _netdev_info_ifconfig(ifcfg_out)
    else:
        LOG.warning(
            "Could not print networks: missing 'ip' and 'ifconfig' commands")

    if empty == "":
        return devs

    recurse_types = (dict, tuple, list)

    def fill(data, new_val="", empty_vals=("", b"")):
        """Recursively replace 'empty_vals' in data (dict, tuple, list)
           with new_val"""
        if isinstance(data, dict):
            myiter = data.items()
        elif isinstance(data, (tuple, list)):
            myiter = enumerate(data)
        else:
            raise TypeError("Unexpected input to fill")

        for key, val in myiter:
            if val in empty_vals:
                data[key] = new_val
            elif isinstance(val, recurse_types):
                fill(val, new_val)

    fill(devs, new_val=empty)
    return devs


def _netdev_route_info_iproute(iproute_data):
    """
    Get network route dicts from ip route info.

    @param iproute_data: Output string from ip route command.

    @returns: A dict containing ipv4 and ipv6 route entries as lists. Each
              item in the list is a route dictionary representing destination,
              gateway, flags, genmask and interface information.
    """

    routes = {}
    routes['ipv4'] = []
    routes['ipv6'] = []
    entries = iproute_data.splitlines()
    default_route_entry = {
        'destination': '', 'flags': '', 'gateway': '', 'genmask': '',
        'iface': '', 'metric': ''}
    for line in entries:
        entry = copy(default_route_entry)
        if not line:
            continue
        toks = line.split()
        flags = ['U']
        if toks[0] == "default":
            entry['destination'] = "0.0.0.0"
            entry['genmask'] = "0.0.0.0"
        else:
            if '/' in toks[0]:
                (addr, cidr) = toks[0].split("/")
            else:
                addr = toks[0]
                cidr = '32'
                flags.append("H")
                entry['genmask'] = net_prefix_to_ipv4_mask(cidr)
            entry['destination'] = addr
            entry['genmask'] = net_prefix_to_ipv4_mask(cidr)
            entry['gateway'] = "0.0.0.0"
        for i in range(len(toks)):
            if toks[i] == "via":
                entry['gateway'] = toks[i + 1]
                flags.insert(1, "G")
            if toks[i] == "dev":
                entry["iface"] = toks[i + 1]
            if toks[i] == "metric":
                entry['metric'] = toks[i + 1]
        entry['flags'] = ''.join(flags)
        routes['ipv4'].append(entry)
    try:
        (iproute_data6, _err6) = util.subp(
            ["ip", "--oneline", "-6", "route", "list", "table", "all"],
            rcs=[0, 1])
    except util.ProcessExecutionError:
        pass
    else:
        entries6 = iproute_data6.splitlines()
        for line in entries6:
            entry = {}
            if not line:
                continue
            toks = line.split()
            if toks[0] == "default":
                entry['destination'] = "::/0"
                entry['flags'] = "UG"
            else:
                entry['destination'] = toks[0]
                entry['gateway'] = "::"
                entry['flags'] = "U"
            for i in range(len(toks)):
                if toks[i] == "via":
                    entry['gateway'] = toks[i + 1]
                    entry['flags'] = "UG"
                if toks[i] == "dev":
                    entry["iface"] = toks[i + 1]
                if toks[i] == "metric":
                    entry['metric'] = toks[i + 1]
                if toks[i] == "expires":
                    entry['flags'] = entry['flags'] + 'e'
            routes['ipv6'].append(entry)
    return routes


def _netdev_route_info_netstat(route_data):
    routes = {}
    routes['ipv4'] = []
    routes['ipv6'] = []

    entries = route_data.splitlines()
    for line in entries:
        if not line:
            continue
        toks = line.split()
        # FreeBSD shows 6 items in the routing table:
        #  Destination  Gateway    Flags Refs    Use  Netif Expire
        #  default      10.65.0.1  UGS      0  34920 vtnet0
        #
        # Linux netstat shows 2 more:
        #  Destination  Gateway    Genmask  Flags Metric Ref    Use Iface
        #  0.0.0.0      10.65.0.1  0.0.0.0  UG    0      0        0 eth0
        if (len(toks) < 6 or toks[0] == "Kernel" or
                toks[0] == "Destination" or toks[0] == "Internet" or
                toks[0] == "Internet6" or toks[0] == "Routing"):
            continue
        if len(toks) < 8:
            toks.append("-")
            toks.append("-")
            toks[7] = toks[5]
            toks[5] = "-"
        entry = {
            'destination': toks[0],
            'gateway': toks[1],
            'genmask': toks[2],
            'flags': toks[3],
            'metric': toks[4],
            'ref': toks[5],
            'use': toks[6],
            'iface': toks[7],
        }
        routes['ipv4'].append(entry)

    try:
        (route_data6, _err6) = util.subp(
            ["netstat", "-A", "inet6", "--route", "--numeric"], rcs=[0, 1])
    except util.ProcessExecutionError:
        pass
    else:
        entries6 = route_data6.splitlines()
        for line in entries6:
            if not line:
                continue
            toks = line.split()
            if (len(toks) < 7 or toks[0] == "Kernel" or
                    toks[0] == "Destination" or toks[0] == "Internet" or
                    toks[0] == "Proto" or toks[0] == "Active"):
                continue
            entry = {
                'destination': toks[0],
                'gateway': toks[1],
                'flags': toks[2],
                'metric': toks[3],
                'ref': toks[4],
                'use': toks[5],
                'iface': toks[6],
            }
            # skip lo interface on ipv6
            if entry['iface'] == "lo":
                continue
            # strip /128 from address if it's included
            if entry['destination'].endswith('/128'):
                entry['destination'] = re.sub(
                    r'\/128$', '', entry['destination'])
            routes['ipv6'].append(entry)
    return routes


def route_info():
    routes = {}
    if util.which('ip'):
        # Try iproute first of all
        (iproute_out, _err) = util.subp(["ip", "-o", "route", "list"])
        routes = _netdev_route_info_iproute(iproute_out)
    elif util.which('netstat'):
        # Fall back to net-tools if iproute2 is not present
        (route_out, _err) = util.subp(
            ["netstat", "--route", "--numeric", "--extend"], rcs=[0, 1])
        routes = _netdev_route_info_netstat(route_out)
    else:
        LOG.warning(
            "Could not print routes: missing 'ip' and 'netstat' commands")
    return routes


def netdev_pformat():
    lines = []
    empty = "."
    try:
        netdev = netdev_info(empty=empty)
    except Exception as e:
        lines.append(
            util.center(
                "Net device info failed ({error})".format(error=str(e)),
                '!', 80))
    else:
        if not netdev:
            return '\n'
        fields = ['Device', 'Up', 'Address', 'Mask', 'Scope', 'Hw-Address']
        tbl = SimpleTable(fields)
        for (dev, data) in sorted(netdev.items()):
            for addr in data.get('ipv4'):
                tbl.add_row(
                    (dev, data["up"], addr["ip"], addr["mask"],
                     addr.get('scope', empty), data["hwaddr"]))
            for addr in data.get('ipv6'):
                tbl.add_row(
                    (dev, data["up"], addr["ip"], empty,
                     addr.get("scope6", empty), data["hwaddr"]))
            if len(data.get('ipv6')) + len(data.get('ipv4')) == 0:
                tbl.add_row((dev, data["up"], empty, empty, empty,
                             data["hwaddr"]))
        netdev_s = tbl.get_string()
        max_len = len(max(netdev_s.splitlines(), key=len))
        header = util.center("Net device info", "+", max_len)
        lines.extend([header, netdev_s])
    return "\n".join(lines) + "\n"


def route_pformat():
    lines = []
    try:
        routes = route_info()
    except Exception as e:
        lines.append(
            util.center(
                'Route info failed ({error})'.format(error=str(e)),
                '!', 80))
        util.logexc(LOG, "Route info failed: %s" % e)
    else:
        if routes.get('ipv4'):
            fields_v4 = ['Route', 'Destination', 'Gateway',
                         'Genmask', 'Interface', 'Flags']
            tbl_v4 = SimpleTable(fields_v4)
            for (n, r) in enumerate(routes.get('ipv4')):
                route_id = str(n)
                tbl_v4.add_row([route_id, r['destination'],
                                r['gateway'], r['genmask'],
                                r['iface'], r['flags']])
            route_s = tbl_v4.get_string()
            max_len = len(max(route_s.splitlines(), key=len))
            header = util.center("Route IPv4 info", "+", max_len)
            lines.extend([header, route_s])
        if routes.get('ipv6'):
            fields_v6 = ['Route', 'Destination', 'Gateway', 'Interface',
                         'Flags']
            tbl_v6 = SimpleTable(fields_v6)
            for (n, r) in enumerate(routes.get('ipv6')):
                route_id = str(n)
                if r['iface'] == 'lo':
                    continue
                tbl_v6.add_row([route_id, r['destination'],
                                r['gateway'], r['iface'], r['flags']])
            route_s = tbl_v6.get_string()
            max_len = len(max(route_s.splitlines(), key=len))
            header = util.center("Route IPv6 info", "+", max_len)
            lines.extend([header, route_s])
    return "\n".join(lines) + "\n"


def debug_info(prefix='ci-info: '):
    lines = []
    netdev_lines = netdev_pformat().splitlines()
    if prefix:
        for line in netdev_lines:
            lines.append("%s%s" % (prefix, line))
    else:
        lines.extend(netdev_lines)
    route_lines = route_pformat().splitlines()
    if prefix:
        for line in route_lines:
            lines.append("%s%s" % (prefix, line))
    else:
        lines.extend(route_lines)
    return "\n".join(lines)

# vi: ts=4 expandtab

Youez - 2016 - github.com/yon3zu
LinuXploit