HEX
Server: LiteSpeed
System: Linux cpir1.prohostdns.com 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP Thu May 7 23:17:13 UTC 2026 x86_64
User: pelakir (2976)
PHP: 8.2.31
Disabled: exec, shell_exec, system, passthru, proc_open, proc_close, proc_terminate, proc_get_status, popen, pclose, pcntl_exec
Upload Files
File: //proc/thread-self/root/lib/python3.6/site-packages/sshuttle/__pycache__/firewall.cpython-36.pyc
3

��^�'�@s�ddlZddlZddlZddlZddlZddlZddlZddljZddl	m
Z
mZmZddl
mZmZdZdd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)�N)�debug1�debug2�Fatal)�get_auto_method�
get_methodz
/etc/hostscCsfdt}d|}d}d}ytt�j�}tjt�}Wn2tk
rd}z|jtjkrRn�WYdd}~XnX|j�r�tj	j
|�r�tjt|�dt|f}t|d�}x4|j�j
d�D]"}	|	j|�dkr�q�|jd|	�q�Wx2t|j��D]"\}
}|jd	d
||
f|f�q�W|j�|dk	�r<tj||j|j�tj||j�ntj|dd�tj|d�tj|t�dS)Nz%s.sbakz"# sshuttle-firewall-%d AUTOCREATED�z	%s.%d.tmp�w�
rz%s
z	%-30s %s
z%s %si�)�	HOSTSFILE�open�read�os�stat�IOError�errno�ENOENT�strip�path�exists�link�rstrip�split�find�write�sorted�items�close�chown�st_uid�st_gid�chmod�st_mode�rename)�hostmap�portZBAKFILEZAPPENDZold_content�st�eZtmpname�f�line�name�ip�r+�/usr/lib/python3.6/firewall.py�rewrite_etc_hostss8

r-cCsti|�dS)N)r-)r$r+r+r,�restore_etc_hosts2sr.cCsttj�dkrtd��tjtjtj�tjtjtj�tjtjtj�tjtjtj�tj	�tj
dd�tjtj
fS)Nrz8you must be root (or enable su/sudo) to set the firewall�)r
�getuidr�signal�SIGHUP�SIG_IGN�SIGPIPE�SIGTERM�SIGINT�setsid�dup2�sys�stdin�stdoutr+r+r+r,�setup_daemon7sr<cCs$|d|dpd|d|dfS)Nr/�i��������i��r+)�sr+r+r,�
subnet_weightTsrAcDCs�t�\}}i}tdtj��|dkr.t�}nt|�}|rJtj�tj�td|j	�|j
d|j	�|j�|jd�}|s�dSg}|dkr�t
d|��x�|jd�}|s�t
d|��n|jd	�r�Py |j�jd
d�\}}	}
}}}
Wn"tk
�rt
d|��YnX|jt|�t|	�tt|
��|t|�t|
�f�q�Wtd
|�g}|d	k�r`t
d|��x�|jd�}|�s�t
d|��n|jd��r�Py|j�jd
d�\}}Wn"tk
�r�t
d|��YnX|jt|�|f�td|��qbWtd|�|jd��st
d|��|jd�\}}}|jd
�}t|�dk�rJt
dt|���t|d�}t|d�}t|d�}t|d�}|dk�s�t�|dk�s�t�|dk�s�t�|dk�s�t�|dk�s�t�|dk�s�t�|dk�s�t�|dk�s�t�td||||f�|jd�}|�st
d|��n|jd��s4t
d|��|jd�\}}}|j�jdd�\}}tt|��}|d k�rrd}td!||f�d"d#�|D�}d$d#�|D�}d%d#�|D�}d&d#�|D�}�ztd'�|�s�|�r�td(�|j|||tj|||�|�s�|�rtd)�|j|||tj|||�|j
d*�y|j�Wntk
�rJdSXx||jd�}|jd+��r�|dd�j�jd
d�\}}|||<td,�t||�p�|�n"|�r�|j|��s�t
d-|��nP�qNWWdytd.�Wntk
�r�td/�YnXy*|�s|�r"td0�|j |tj||�Wnftk
�r�y0td1�x"t!j"�j#�D]}td2|��qNWWntk
�r�td/�YnXYnXy*|�s�|�r�td3�|j |tj||�Wnftk
�ry0td4�x"t!j"�j#�D]}td5|��q�WWntk
�rtd/�YnXYnXytd6�t$|�p2|�Wnftk
�r�y0td7�x"t!j"�j#�D]}td5|��qbWWntk
�r�td/�YnXYnXXdS)8Nz;firewall manager: Starting firewall with Python version %s
�autoz(firewall manager: ready method name %s.
z	READY %s
�zROUTES
z$firewall: expected ROUTES but got %rz#firewall: expected route but got %rzNSLIST
�,�z-firewall: expected route or NSLIST but got %rz"firewall manager: Got subnets: %r
z$firewall: expected NSLIST but got %rz$firewall: expected nslist but got %rzPORTS r/z-firewall: expected nslist or PORTS but got %rz)firewall manager: Got partial nslist: %r
z!firewall manager: Got nslist: %r
z#firewall: expected PORTS but got %r� �z%firewall: expected 4 ports but got %drr=�i��z)firewall manager: Got ports: %d,%d,%d,%d
z firewall: expected GO but got %rzGO �-z(firewall manager: Got udp: %r, user: %r
cSsg|]}|dtjkr|�qS)r)�socket�AF_INET6)�.0�ir+r+r,�
<listcomp>�szmain.<locals>.<listcomp>cSsg|]}|dtjkr|�qS)r)rJrK)rLrMr+r+r,rN�scSsg|]}|dtjkr|�qS)r)rJ�AF_INET)rLrMr+r+r,rN�scSsg|]}|dtjkr|�qS)r)rJrO)rLrMr+r+r,rN�szfirewall manager: setting up.
z#firewall manager: setting up IPv6.
z#firewall manager: setting up IPv4.
zSTARTED
zHOST z)firewall manager: setting up /etc/hosts.
z"firewall: expected command, got %rz#firewall manager: undoing changes.
zAn error occurred, ignoring it.z(firewall manager: undoing IPv6 changes.
z6firewall manager: Error trying to undo IPv6 firewall.
z---> %s
z(firewall manager: undoing IPv4 changes.
z6firewall manager: Error trying to undo IPv4 firewall.
zfirewall manager: ---> %s
z.firewall manager: undoing /etc/hosts changes.
z;firewall manager: Error trying to undo /etc/hosts changes.
)%r<r�platformZpython_versionrr�ssyslogZstart_syslogZstderr_to_syslogr)r�flush�readliner�
startswithrr�
BaseException�append�int�boolr�	partition�len�AssertionErrorZsetup_firewallrJrKrOrr-Zfirewall_commandZrestore_firewall�	traceback�
format_exc�
splitlinesr.)Zmethod_nameZsyslogr:r;r#�methodr(ZsubnetsZfamily�width�excluder*ZfportZlportZnslist�_ZportsZport_v6Zport_v4Z
dnsport_v6Z
dnsport_v4�argsZudp�userZ
subnets_v6Z	nslist_v6Z
subnets_v4Z	nslist_v4r)r+r+r,�main`s4



 







re)rrJr1r9r
rPr\Zsshuttle.ssyslogrQZsshuttle.helpersrrrZsshuttle.methodsrrr
r-r.r<rArer+r+r+r,�<module>s
"