Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
save.cpython-313.pyc50 linesDownload Raw Back to __pycache__
1�

2��j���B�SSKrSSKrSSKrSSKJr SSKJr SSKJr SSK	J3r4 SSKJr SSKJ
r
 SSKrSSKJr SS	KJr SS5KJr SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr \S\S\4Sj5r\S\S\S4Sj5r"SS5rg)�N)�Sequence)�datetime)�	lru_cache)�Path)�Literal)�Optional)�command)�ctx)�dns)�6exceptions)�flow)�7flowfilter)�http)�io)�tcp)�udp)�ALERT�path�returnc�v�URS5(aUSSn[RRU5$)zLExtract the path from a path spec (which may have an extra "+" at the front)�+�N)�8startswith�osr�9expanduser�rs �[D:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/addons/save.py�_pathrs3�����s����A�B�x��
�7�7���d�#�#�)�ab�wbc�2�URS5(agg)z?Extract the writing mode (overwrite or append) from a path specrr r!)rrs r�_moder#!s�����s����rc��\rSrSrSSjrSrSrSSjrS\RSS4S	jr10SS11jr\R"S5S\
\RS
\RR SS4Sj5rS\R&4SjrS\R&4SjrS\R&4SjrS\R04SjrS\R04SjrS\R04SjrS\R:4SjrS\R:4SjrS\R:4Sjr S\R:4Sjr!S\"RF4Sjr$S\"RF4Sjr%S\"RF4Sjr&Sr'g)�Save�*rNc�L�SUlSUl[5UlSUlg�N)�stream�filt�set�active_flows�current_path)�selfs r�__init__�
Save.__init__+s"��48���/3��	�,/�E���(,��rc��URS[[SS5 URS[[SS5 g)N�save_stream_filea12            Stream flows to file as they arrive. Prefix path with + to append.13            The full path can use python strftime() formating, missing14            directories are created as needed. A new file is opened every time15            the formatted string changes.16            �save_stream_filterz'Filter which flows are written to file.)�17add_optionr�str)r.�loaders  r�load�	Save.load1sB�������S�M��
�	18	19�	��� ��S�M��5�		20rc��SU;a[[RR(a5[R"[RR5UlOSUlSU;dSU;ap[RR(a@UR5 UR(deUR21URlgUR5 gg![a%n[R"[U55UeSnAff=f![a%n[R"[U55UeSnAff=f)Nr3r2)r22�optionsr3r�parser*�23ValueErrorr�OptionsErrorr5r2�maybe_rotate_to_new_file�OSErrorr)�flt�done)r.�updated�es   r�	configure�Save.configureDs����7�*��{�{�-�-�A� *� 0� 0����1O�1O� P�D�I�!��	���(�,@�G�,K��{�{�+�+�A��1�1�3��{�{�"�{�"&�)�)������	�	��-L��	"�A�$�1�1�#�a�&�9�q�@��A���A�$�1�1�#�a�&�9�q�@��A�s/�3C�D�24D�) D	�	D�25E� D;�;Ec�,�[R"5R[[R26R55nURU:XagUR(a+URRR5 SUl[U5nURRSSS9 UR[[R27R55n[ R""X0R$5UlXlg)NT)�parents�exist_ok)r�today�strftimerr28r:r2r-r)�fo�closer�parent�mkdir�openr#r�FilteredFlowWriterr*)r.r�new_log_file�fs    rr>�Save.maybe_rotate_to_new_fileXs����~�~��(�(��s�{�{�/K�/K�)L�M������$���;�;��K�K�N�N� � �"��D�K��D�z�����!�!�$��!�>����e�C�K�K�$@�$@�A�B���+�+�A�y�y�9��� �rr
c�n�UR(dgUR5 URRU5 URR	U5 g![29aOn[RRSURSU35 [R"S5 SnAgSnAff=f)zS30Write the flow to the stream, but first check if we need to rotate to a new file.31NzError while writing to z: r)r)r>�addr,�discardr?�sys�stderr�writer-�exit)r.r
rCs   r�	save_flow�Save.save_flowhs����{�{��32	,��)�)�+��K�K�O�O�D�!�
���%�%�d�+���	�
�J�J���6�t�7H�7H�6I��A�3�O�P��H�H�Q�K�K��	�s�+A�33B4�%AB/�/B4c��UR(a{URHnURRU5 M  URR5 SUlURR34R
5 SUlggr()r)r,rU�clearr-rKrL)r.rRs  rrA�	Save.donezsc���;�;��&�&��������"�'����#�#�%� $�D���K�K�N�N� � �"��D�K�rz	save.file�flowsrc��[[U5[U55n[R"U5nUHnURU5 M SSS5 URS5(dURS5(a[R"[S5 g[R"[S[U5S35 g!,(df   N=f![an[R"U5UeSnAff=f)zr35Save flows to a file. If the path starts with a +, flows are36appended to the file, otherwise it is over-written.37Nz.harz.zharzLSaved as mitmproxy dump file. To save HAR files, use the `save.har` command.zSaved z flows.)rOrr#r�38FlowWriterrUr?r�CommandError�endswith�logging�logr�len)r.r`rrRr)�irCs       r�save�	Save.save�s���	4��e�D�k�5��;�/�1����q�)���A��J�J�q�M��0��=�=�� � �D�M�M�'�$:�$:��K�K��^�
�39
�K�K����E�40�|�7�;�<�0�/���	4��)�)�!�,�!�3��	4�s4�C�1C41�C�42 43C�C�C�44D�%C<�<Dc�^�UR(aURRU5 ggr(�r)r,rU�r.r
s  r�	tcp_start�Save.tcp_start��"���;�;����!�!�$�'�rc�&�URU5 gr(�r[rms  r�tcp_end�Save.tcp_end�������t�rc�&�URU5 gr()rsrms  r�	tcp_error�Save.tcp_error�������T�rc�^�UR(aURRU5 ggr(rlrms  r�	udp_start�Save.udp_start�rprc�&�URU5 gr(rrrms  r�udp_end�Save.udp_end�rurc�&�URU5 gr()r~rms  r�	udp_error�Save.udp_error�ryrc�&�URU5 gr(rrrms  r�
websocket_end�Save.websocket_end�rurc�^�UR(aURRU5 ggr(rlrms  r�request�Save.request�rprc�B�URcURU5 ggr()�	websocketr[rms  r�response�
Save.response�s���>�>�!��N�N�4� �"rc�&�URU5 gr()r�rms  r�error�45Save.error�s���
�
�d�rc�^�UR(aURRU5 ggr(rlrms  r�dns_request�Save.dns_request�rprc�&�URU5 gr(rrrms  r�dns_response�Save.dns_response�rurc�&�URU5 gr(rrrms  r�	dns_error�Save.dns_error�rur)r,r-r*r))rN)(�__name__�46__module__�__qualname__�__firstlineno__r/r7rDr>r
�Flowr[rAr	r�	mitmproxy�typesrrir�TCPFlowrnrsrwr�UDPFlowr{r~r�r�HTTPFlowr�r�r�r�r�DNSFlowr�r�r��__static_attributes__�rrr%r%*sG��-�47�&�(!� ,�d�i�i�,�D�,�$�
�_�_�[�!�=�(�4�9�9�-�=�Y�_�_�5I�5I�=�d�=�"�=�((�c�k�k�(��C�K�K���c�k�k��(�c�k�k�(��C�K�K���c�k�k���$�-�-��(�D�M�M�(�!�T�]�]�!��$�-�-��(����(�������c�k�k�rr%) re�os.pathrrW�collections.abcrr�	functoolsr�pathlibr�typingrr�mitmproxy.typesr�r	r48rrr
rrrrr�
mitmproxy.logrr5rr#r%r�rr�<module>r�s�����49�$���������� �� �������$��$��$��$������50�+����[�[r
codekingpro/portable-devtools · Team Ai