ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib/python2.7/site-packages/isc/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib/python2.7/site-packages/isc/rndc.pyc

�
���cc@s~ddlmZddlZddlZddlZddlZddlZddlZddlZde	fd��YZ
dS(i����(tOrderedDictNtrndccBs�eZdZidd6dd6dd6dd6d	d
6dd6Zd
�Zd�Zed�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
RS(sRNDC protocol client libraryi�tmd5i�tsha1i�tsha224i�tsha256i�tsha384i�tsha512cCs�||_|j�}|jd�r1|d}n||_tt|�|_tj|�|_	t
jdd�|_d|_|j�dS(s�Creates a persistent connection to RNDC and logs in
        host - (ip, port) tuple
        algo - HMAC algorithm: one of md5, sha1, sha224, sha256, sha384, sha512
               (with optional prefix 'hmac-')
        secret - HMAC secret, base64 encodedshmac-iiiiNi(thosttlowert
startswithtalgotgetattrthashlibthlalgotbase64t	b64decodetsecrettrandomtrandinttsertNonetnoncet_rndc__connect_login(tselfRRR((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__init__$s	
		cCst|jd|�d�S(s�Call a RNDC command, all parsing is done on the server side
        cmd - a complete string with a command (eg 'reload zone example.com')
        ttypet_data(tdictt_rndc__command(Rtcmd((s,/usr/lib/python2.7/site-packages/isc/rndc.pytcall5scCsyt�}xi|j�D][\}}|r:|dkr:qn|tjdt|��|jd�7}t|�tkr�|tjddt|��|jd�7}qt|�tkr�|tjddt|��|7}qt|�tkr|tjddt|��|7}qt|�t	kr[|j
|�}|tjddt|��|7}qtdt|���qW|S(Nt_authtBtasciis>BIiis#Cannot serialize element of type %s(t	bytearraytitemststructtpacktlentencodeRtstrtbytesRt_rndc__serialize_dicttNotImplementedError(Rtdatatignore_authtrvtktvtsd((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__serialize_dict;s"	)/&&&c	Os�|jd7_ttj��}t||�}t�}t�|d<t�|d<t|j�|dd<t|�|dd<t|d�|dd<|jdk	r�|j|dd<n||d	<|j|d
t�}t	j
|j||j�j
�}tj|�}|jdkr4tjd|�|dd
<n-ttjd|j|j|��|dd<|j|�}tjdt|�dd�|}|S(NiR t_ctrlt_sert_timi<t_expt_nonceRR.Rt22sthmd5tB88sthshas>IIi(RtintttimeRR)RRR+tTruethmactnewRRtdigestRt	b64encodeRR%R&R#t_rndc__algosR'(	RtargstkwargstnowR-tdtmsgthashtbhash((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__prep_messageOs,	


!!#cCs�|jdk	r*|dd|jkr*tS|jdkrJ|dd}n|ddd}t|�tkr�|jd�}n|d	d
t|�d
7}tj	|�}|j
|dt�}tj
|j||j�j�}||kS(NR4R8RR R:R<iR"t=iR.(RRtFalseRRR*tdecodeR'RRR+R?R@RARRRB(RRIRKtremote_hashtmy_msgtmy_hash((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__verify_msgjs&!c	OsD|j||�}|jj|�}|t|�krEtd��n|jjd�}t|�dkrxtd��ntjd|�\}}|dkr�td|��n|d8}|jj|tj	�}t|�|kr�td��nt
|�tkrt|�}n|j
|�}|j|�s@td	��n|S(
NsCannot send the messageisCan't read response headers>IIisWrong message version %disCan't read response datasAuthentication failure(t_rndc__prep_messagetsockettsendR'tIOErrortrecvR%tunpackR,tMSG_WAITALLRR)R#t_rndc__parse_messaget_rndc__verify_msg(	RRERFRItsenttheadertlengthtversionR-((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt	__commandys(
cCsEtj|j�|_d|_|jdd�}|dd|_dS(NRtnullR4R8(RUtcreate_connectionRRRR(RRI((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__connect_login�s	cCs,d}||}|d7}||||!jd�}||7}||}|d7}tjd|||d!�d}|d7}||||!}||7}||}|dkr�|||fS|dkrt�}	x8t|�dkr
|j|�\}
}}||	|
<q�W||	|fStd|��dS(NiiR"s>IiisUnknown element type %d(ROR%RYRR't_rndc__parse_elementR,(RtinputtpostlabellentlabelRtdatalenR-trestRHtilabeltvalue((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__parse_element�s*




!



	
cCsNt�}d}x8t|�dkrI|j|�\}}}|||<qW|S(Ni(RRR'Re(RRfR/thdataRiRm((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt__parse_message�s	(t__name__t
__module__t__doc__RDRRRNR+RTR\RRReR[(((s,/usr/lib/python2.7/site-packages/isc/rndc.pyRs 

							(tcollectionsRR>R%R
R@RRRUtobjectR(((s,/usr/lib/python2.7/site-packages/isc/rndc.pyt<module>s

Zerion Mini Shell 1.0