%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_network.pyo

�
���^c@@sNdZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
mamamamamamamamamamamaddlmZyddlZ
eZWnek
re ZnXddl!j"j#Z#yddl$Z$Wnek
r=e ZnXddl%m&Z&dZ'd�Z(e e d	�Z)d
�Z*d�Z+d�Z,d
�Z-d�Z.d�Z/d�Z0d�Z1e
j2j3j4e1d�Z5d�Z6d�Z7de ddd�Z9e
j2j3j4e9d�Z:de dd�Z;e
j2j3j4e;d�Z<dd�Z=d�Z>dS(u7
Module for gathering and managing network information
i(tabsolute_importtunicode_literalstprint_functionN(twoltget_hostnamet	interfacetinterface_iptsubnets6tip_in_subnettconvert_cidrtcalc_nettget_fqdntifacestartswithtiphexval(tnamespaced_function(t	ipaddressunetworkcC@s�tjjj�stdfSts,tdfSttt��att	t��a	tt
t��a
ttt��attt��att
t��a
ttt��attt��attt��attt��attt��atS(u'
    Only works on Windows systems
    u-Module win_network: Only available on Windowsu(Module win_network: Missing dependencies(tsalttutilstplatformt
is_windowstFalsetHAS_DEPENDENCIESt_namespaced_functionRtglobalsRRRRRR	R
RRR
t__virtualname__(((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyt__virtual__)s 

cC@s�|rMt|�dd}ddddtj|�tjjj|�g}n!dddtjjj|�g}|r�td|dt�}|d	d
kr�tSt	Sntd|dt�SdS(
u�
    Performs a ping to a host

    CLI Example:

    .. code-block:: bash

        salt '*' network.ping archlinux.org

    .. versionadded:: 2016.11.0

    Return a True or False instead of ping output.

    .. code-block:: bash

        salt '*' network.ping archlinux.org return_boolean=True

    Set the time to wait for a response in seconds.

    .. code-block:: bash

        salt '*' network.ping archlinux.org timeout=3
    i�iupingu-nu4u-wucmd.run_alltpython_shelluretcodeiucmd.runN(
tinttsixt	text_typeRRtnetworkt
sanitize_hostt__salt__RtTrue(thostttimeouttreturn_booleantcmdtret((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pytpingEs3!cC@s�g}ddg}td|dt�j�}x�|D]�}|j�}|jd�r�|ji|dd6|dd	6|d
d6|dd
6|dd6�n|jd�r5|ji|dd6|dd	6|d
d6dd
6|dd6�q5q5W|S(u�
    Return information on open ports and states

    CLI Example:

    .. code-block:: bash

        salt '*' network.netstat
    unetstatu-naoucmd.runRu  TCPiu
local-addressiuprotoiuremote-addressiustateiuprogramu  UDPN(R Rt
splitlinestsplitt
startswithtappendtNone(R&R%tlinestlinetcomps((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pytnetstatns(

		cC@s�g}dtjjj|�g}td|dt�j�}xg|D]_}d|kr\qDn|jd�rqqDn|jd�r�qDn|j�}t	|�}|dkri|dd	6|d
d6|dd
6|dd6|dd6|dd6}|j
|�qD|dkrbi|dd	6dd6|d
d
6|dd6|dd6|dd6}|j
|�qDi|dd	6dd6dd
6dd6dd6dd6}|j
|�qDW|S(u�
    Performs a traceroute to a 3rd party host

    CLI Example:

    .. code-block:: bash

        salt '*' network.traceroute archlinux.org
    utracertucmd.runRu uTracuoveri	iucountiuhostnameiuipiums1iums2iums3N(RRRRR RR(R*R)tlenR+R,(R"R&R%R-R.R/t
complengthtresult((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyt
traceroute�sN


cC@s-g}g}dtjjj|�g}td|dt�j�}x�|D]�}|ro|j|j��qJn|j	d�r�qJnd|kr�|j
dd�}|j|dj��qJnd|krJ|j
dd�}|ji|dj�|dj�6�qJqJW|r)|ji|d6�n|S(	u�
    Query DNS for information about a domain or ip address

    CLI Example:

    .. code-block:: bash

        salt '*' network.nslookup archlinux.org
    unslookupucmd.runRuNon-authoritativeu	Addressesu:ii(RRRRR RR(R+tstripR*R)(R"R&t	addressesR%R-R.R/((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pytnslookup�s(

/cC@s�dj|�}td|dddt�}tjddtjtjB�}|j|�}i|d6|jd	�d	6|jd
�d
6|jd�d6}|S(u�
    Return routing information for given destination ip

    .. versionadded:: 2016.11.5

    CLI Example::

        salt '*' network.get_route 10.10.10.10
    u"Find-NetRoute -RemoteIPAddress {0}ucmd.runtshellu
powershellRu~^IPAddress\s+:\s(?P<source>[\d\.:]+)?.*^InterfaceAlias\s+:\s(?P<interface>[\w\.\:\-\ ]+)?.*^NextHop\s+:\s(?P<gateway>[\d\.:]+)tflagsudestinationugatewayu	interfaceusource(	tformatR R!tretcompilet	MULTILINEtDOTALLtsearchtgroup(tipR%touttregexptmR&((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyt	get_route�s
cC@s/dtjjj|�g}td|dt�S(u�
    Performs a DNS lookup with dig

    Note: dig must be installed on the Windows minion

    CLI Example:

    .. code-block:: bash

        salt '*' network.dig archlinux.org
    udigucmd.runR(RRRRR R(R"R%((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pytdigscC@s\g}tjjj��>tj�}x*|jdt�D]}|j|j	�q8WWdQX|S(u�
    Return a list of all the interfaces names

    CLI Example:

    .. code-block:: bash

        salt '*' network.interfaces_names
    t
NetEnabledN(
RRtwinapitComtwmitWMItWin32_NetworkAdapterR!R+tNetConnectionID(R&tctiface((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pytinterfaces_namesscC@stjjj�S(u�
    Return a dictionary of information about all the interfaces on the minion

    CLI Example:

    .. code-block:: bash

        salt '*' network.interfaces
    (RRRtwin_interfaces(((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyt
interfaces%s
cC@stjjj|�S(u�
    Return the hardware address (a.k.a. MAC address) for a given interface

    CLI Example:

    .. code-block:: bash

        salt '*' network.hw_addr 'Wireless Connection #1'
    (RRRthw_addr(RO((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRS2s
uhwaddrcC@stjjj�S(u�
    Returns a list of subnets to which the host belongs

    CLI Example:

    .. code-block:: bash

        salt '*' network.subnets
    (RRRtsubnets(((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRTCs
cC@stjjj|�S(u�
    Returns True if host is within specified subnet, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' network.in_subnet 10.0.0.0/16
    (RRRt	in_subnet(tcidr((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRUPs
cC@s�tjjjd|d|�}|rVg|D]'}tjjj||g�r+|^q+S|dkr�g|D]}t|�si|^qiS|dkr�g|D]}t|�r�|^q�S|SdS(u�
    Returns a list of IPv4 addresses assigned to the host.

    interface
        Only IP addresses from that interface will be returned.

    include_loopback : False
        Include loopback 127.0.0.1 IPv4 address.

    cidr
        Describes subnet using CIDR notation and only IPv4 addresses that belong
        to this subnet will be returned.

      .. versionchanged:: 2019.2.0

    type
        If option set to 'public' then only public addresses will be returned.
        Ditto for 'private'.

        .. versionchanged:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' network.ip_addrs
        salt '*' network.ip_addrs cidr=10.0.0.0/8
        salt '*' network.ip_addrs cidr=192.168.0.0/16 type=private
    Rtinclude_loopbackupublicuprivateN(RRRtip_addrsRUt
is_private(RRWRVttypetaddrsti((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRX]s	2##uipaddrscC@s^tjjjd|d|�}|rVg|D]'}tjjj||g�r+|^q+S|SdS(u
    Returns a list of IPv6 addresses assigned to the host.

    interface
        Only IP addresses from that interface will be returned.

    include_loopback : False
        Include loopback ::1 IPv6 address.

    cidr
        Describes subnet using CIDR notation and only IPv6 addresses that belong
        to this subnet will be returned.

        .. versionchanged:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' network.ip_addrs6
        salt '*' network.ip_addrs6 cidr=2000::/3
    RRWN(RRRt	ip_addrs6RU(RRWRVR[R\((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyR]�s
	2uipaddrs6cK@s�idd6dd6}|s2t|d<d|d<|S|sPt|d<d|d<|S|jdd�}|jdd	�}|jd
d�}tjjjj|�s�tjjjj|�r�|}ndj	tjj
j|��}yO|dkr�tj
}ntj}d}|rF|d
kr%tj}	qL|dkr=tj}	qLd}	nd}	tj|||	d|�d\}}
}}}
tj||
|�}|j|�|dkrtj�}|jtjj�jd��|j�}|j||
�|jd�\}}|j�n|j|
�|jd�Wn>tk
rl}t|d<dj	||
d||�|d<|SXt |d<dj	||
d||�|d<|S(u�
    Test connectivity to a host using a particular
    port from the minion.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' network.connect archlinux.org 80

        salt '*' network.connect archlinux.org 80 timeout=3

        salt '*' network.connect archlinux.org 80 timeout=3 family=ipv4

        salt '*' network.connect google-public-dns-a.google.com port=53 proto=udp timeout=3
    uresultuucommentu$Required argument, host, is missing.u$Required argument, port, is missing.uprotoutcputimeoutiufamilyu{0}uudpuipv4uipv6iu%si�iu.Unable to connect to {0} ({1}) on {2} port {3}u3Successfully connected to {0} ({1}) on {2} port {3}N(!R,RtgetRRtvalidatetnett	ipv4_addrt	ipv6_addrR:RRtsockettSOL_UDPtSOL_TCPtAF_INETtAF_INET6tgetaddrinfot
settimeoutthashlibtmd5tupdatetdatetimetnowtstrftimet	hexdigesttsendtotrecvfromtclosetconnecttshutdownt	ExceptionR!(R"tporttkwargsR&tprotoR#tfamilytaddresst__protot__familytsocktypet_prototgarbaget_addresstskttmd5htmsgtrecvtsvrtexc((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRt�sb





0			.




cC@stj|�jS(u�
    Check if the given IP address is a private address

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' network.is_private 10.0.0.3
    (Rt
ip_addressRY(tip_addr((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyRY	s(?t__doc__t
__future__RRRR;RjRmRctsalt.utils.networkRtsalt.utils.platformtsalt.utils.validate.nettsalt.modules.networkRRRRRRR	R
RRR
tsalt.utils.functoolsRRtsalt.utils.winapiR!RtImportErrorRtsalt.ext.sixtextRRJtsalt._compatRRRR'R0R4R7RERFRPRRRSRt	functoolstalias_functionthwaddrRTRUR,RXtipaddrsR]tipaddrs6RtRY(((s</usr/lib/python2.7/site-packages/salt/modules/win_network.pyt<module>sRL




	)	 	6	!				
		
	
+\

Zerion Mini Shell 1.0