CasperSecurity

Current Path : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_wireguard.cpython-310.pyc

o

쑛h��
@sUdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
dd	ge
d
gd�Zeed<e�e�Zegd
��ZdZdZdZdefdd�Zdefdd�Zdedefdd�Zdefdd�Zdefdd�Zdefdd�Zd d!�Z d"e!d#e	ded$ed%df
d&d'�Z"dS)(�	Wireguard�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE�cc_wireguard�ubuntu�	wireguard)�id�distros�	frequency�activate_by_schema_keys�meta)�name�config_path�contenti��
)���wg_intcCs�g}t�t|����}|rd�t|��}|�d|���t|���D] \}}|dks2|dks2|dkrBt|t	�sB|�d|�d|���q"|rQt
dt�t�|�����d	S)
aRValidate user-provided wg:interfaces option values.

    This function supplements flexible jsonschema validation with specific
    value checks to aid in triage of invalid user-provided configuration.

    @param wg_int: Dict of configuration value under 'wg:interfaces'.

    @raises: ValueError describing invalid values provided.
    z, z%Missing required wg:interfaces keys: rrrz$Expected a string for wg:interfaces:�. Found z*Invalid wireguard interface configuration:N)�REQUIRED_WG_INT_KEYS�
difference�set�keys�join�sorted�append�items�
isinstance�str�
ValueError�NL)r�errors�missingr�key�value�r)�?/usr/lib/python3/dist-packages/cloudinit/config/cc_wireguard.py�supplemental_schema_validations"

����r+c
Cszt�d|d�zt�d|d�tj|d|dtd�Wd	Sty<}ztd|d�dt�t|����|�d	}~ww)
z�Writing user-provided configuration into Wireguard
    interface configuration file.

    @param wg_int: Dict of configuration value under 'wg:interfaces'.

    @raises: RuntimeError for issues writing of configuration file.
    z"Configuring Wireguard interface %srz#Writing wireguard config to file %srr)�modez-Failure writing Wireguard configuration file �:N)	�LOG�debugr�
write_file�WG_CONFIG_FILE_MODE�	Exception�RuntimeErrorr$r")r�er)r)r*�write_config;s(��������r5�cloudc
Cs�z+t�d|d�|j�dd|d���t�d|d�|j�dd|d���WdStjyD}ztdt�t|����|�d}~ww)	z�Enable and start Wireguard interface

    @param wg_int: Dict of configuration value under 'wg:interfaces'.

    @raises: RuntimeError for issues enabling WG interface.
    zEnabling wg-quick@%s at bootr�enablez	wg-quick@z!Bringing up interface wg-quick@%s�restartz0Failed enabling/starting Wireguard interface(s):N)	r.r/�distro�manage_servicer�ProcessExecutionErrorr3r$r")rr6r4r)r)r*�	enable_wgPs����r<�wg_readinessprobescCsZg}d}|D]}t|t�s|�d|�d|���|d7}q|r+tdt�t�|�����dS)z�Basic validation of user-provided probes

    @param wg_readinessprobes: List of readinessprobe probe(s).

    @raises: ValueError of wrong datatype provided for probes.
    rz(Expected a string for readinessprobe at r�z Invalid readinessProbe commands:N)r!r"rr#r$r)r=r%�pos�cr)r)r*�!readinessprobe_command_validationbs
����rAcCs�g}|D]1}zt�dt|��tj|ddd�Wqtjy5}z|�|�d|���WYd}~qd}~ww|rDtdt�t�|�����dS)z�Execute provided readiness probe(s)

    @param wg_readinessprobes: List of readinessprobe probe(s).

    @raises: ProcessExecutionError for issues during execution of probes.
    zRunning readinessprobe: '%s'T��capture�shellz: Nz&Failed running readinessprobe command:)	r.r/r"rr;rr3r$r)r=r%r@r4r)r)r*�readinessprobexs ����rEcCs�dg}t�d�r
dSt��tkr|�d�z|j��Wnty*t�	t
d��wz	|j�|�WdStyBt�	t
d��w)z�Install wireguard packages and tools

    @param cloud: Cloud object

    @raises: Exception for issues during package
    installation.
    zwireguard-tools�wgNrzPackage update failedz!Failed to install wireguard-tools)r�whichr�kernel_version�MIN_KERNEL_VERSIONrr9�update_package_sourcesr2�logexcr.�install_packages)r6�packagesr)r)r*� maybe_install_wireguard_packages�s"	

��rNc
Cs�z$tjdddd�}t�d|j���s"t�d�tjdddd�WdSWdStjy?}zt�	tdt
�t|�����d}~ww)	zYLoad wireguard kernel module

    @raises: ProcessExecutionError for issues modprobe
    �lsmodTrBrzLoading wireguard kernel modulezmodprobe wireguardz Could not load wireguard module:N)r�re�search�stdout�stripr.r/r;rrKr$r")�outr4r)r)r*�load_wireguard_kernel_module�s
���rUr�cfg�args�returncCs�d}d|vrt�d�|d}nt�d|�dSt|�t�|dD]}t|�t|�t||�q#d|vrK|ddurK|d}t|�t|�dSt�d�dS)Nrz!Found Wireguard section in configz<Skipping module named %s, no 'wireguard' configuration found�
interfacesrEz+Skipping readinessprobe - no checks defined)	r.r/rNrUr+r5r<rArE)rrVr6rW�
wg_sectionrr=r)r)r*�handle�s*

�r[)#�__doc__�loggingrP�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsrr�__annotations__�	getLogger�__name__r.�	frozensetrr1r$rI�dictr+r5r<�listrArErNrUr"r[r)r)r)r*�<module>s4�
"
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY