+
    üÐjÕ1  ã                   óÂ  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHtHtHt ^ RIHtHt ^ RIHt ^ RIHtHtHtHtHt ^ RIHtHt ^ R	IHt ^ R
IH t  ^ RI!H"t" ^ RI#H$t$H%t% . R"Ot&^t']PP                  ! 4       R8X  gM   ]PP                  ! 4       PS                  R4      '       g'   ]PP                  ! 4       PS                  R4      '       d   Rt*Rt+MRt*Rt+Rt, ! R R]4      t-]! ]P\                  4       ! R R]%]$4      4       t/ ! R R]! RR4      4      t0 ! R R]4      t1 ! R R 4      t2]! ]Pf                  4       ! R! R]Ph                  4      4       t5R# )#zc
Support for Linux ethernet and IP tunnel devices.

@see: U{https://en.wikipedia.org/wiki/TUN/TAP}
N)Ú
namedtuple)ÚTuple)Ú	AttributeÚ	InterfaceÚimplementer)ÚFlagConstantÚFlags)ÚVersion)ÚabstractÚdeferÚerrorÚ
interfacesÚtask)ÚethernetÚraw)Úlog)Ú
deprecated)ÚfullyQualifiedName)ÚFancyEqMixinÚFancyStrMixinÚTunnelFlagsÚTunnelAddressÚ
TuntapPortÚpariscÚppcÚsparcl   ÊT  iÒT@iÊT@l   ÒT  s   /dev/net/tunc                   óÚ   € ] tR t^6tRt]! ^4      t]! ^4      t]! ^4      t]! ^ 4      t	]! ^@4      t
]! ^€4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      tRtR	# )
r   aV  
L{TunnelFlags} defines more flags which are used to configure the behavior
of a tunnel device.

@cvar IFF_TUN: This indicates a I{tun}-type device.  This type of tunnel
    carries IP datagrams.  This flag is mutually exclusive with C{IFF_TAP}.

@cvar IFF_TAP: This indicates a I{tap}-type device.  This type of tunnel
    carries ethernet frames.  This flag is mutually exclusive with C{IFF_TUN}.

@cvar IFF_NO_PI: This indicates the I{protocol information} header will
    B{not} be included in data read from the tunnel.

@see: U{https://www.kernel.org/doc/Documentation/networking/tuntap.txt}
é   i   i   é    i @  i €  © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚIFF_TUNÚIFF_TAPÚ
TUN_FASYNCÚTUN_NOCHECKSUMÚ	TUN_NO_PIÚTUN_ONE_QUEUEÚTUN_PERSISTÚTUN_VNET_HDRÚ	IFF_NO_PIÚIFF_ONE_QUEUEÚIFF_VNET_HDRÚIFF_TUN_EXCLÚ__static_attributes__r   ó    Ú5/usr/lib/python3/dist-packages/twisted/pair/tuntap.pyr   r   6   s�   † ññ  ˜6Ó"€GÙ˜6Ó"€Gá˜fÓ%€JÙ! &Ó)€NÙ˜VÓ$€IÙ  Ó(€MÙ˜vÓ&€KÙ Ó'€Lá˜VÓ$€IÙ  Ó(€MÙ Ó'€LÙ Ó'„Lr2   c                   óR   a € ] tR t^Wt o RtR
tRR 3R3t]R 4       tR t	R t
RtV tR	# )r   zM
A L{TunnelAddress} represents the tunnel to which a L{TuntapPort} is bound.
ÚnameÚtypec                ó   € V P                   # ©N)r5   )Úflags   &r3   Ú<lambda>ÚTunnelAddress.<lambda>^   s   € ¨D¯IªIr2   c                ó.   € V P                   P                  # )zu
Return the integer value of the C{type} attribute.  Used to produce
correct results in the equality implementation.
)r6   Úvalue©Úselfs   &r3   Ú
_typeValueÚTunnelAddress._typeValue`   s   € ð �y‰y�‰Ðr2   c                ó   € Wn         W n        R# )z³
@param type: Either L{TunnelFlags.IFF_TUN} or L{TunnelFlags.IFF_TAP},
    representing the type of this tunnel.

@param name: The system name of the tunnel.
@type name: L{bytes}
N)r6   r5   )r?   r6   r5   s   &&&r3   Ú__init__ÚTunnelAddress.__init__i   s   € ð Œ	ØŽ	r2   c                óf   € \         P                  ! R\        ^R7       RV P                  3V,          # )zC
Deprecated accessor for the tunnel name.  Use attributes instead.
zUTunnelAddress.__getitem__ is deprecated since Twisted 14.0.0  Use attributes instead.)ÚcategoryÚ
stacklevelÚTUNTAP)ÚwarningsÚwarnÚDeprecationWarningr5   )r?   Úindexs   &&r3   Ú__getitem__ÚTunnelAddress.__getitem__t   s1   € ô 	�Šð&ä'Øõ		
ð ˜$Ÿ)™)Ð$ UÕ+Ð+r2   )r5   r6   N)r@   r5   )r    r!   r"   r#   r$   ÚcompareAttributesÚshowAttributesÚpropertyr@   rC   rM   r1   Ú__classdictcell__©Ú__classdict__s   @r3   r   r   W   sC   ø‡ € ñð /ÐØÑ5Ð6¸Ð?€Nàñó ðò	÷
,ð 
,r2   c                   ó   € ] tR t^�tRtRtR# )Ú_TunnelDescriptionzª
Describe an existing tunnel.

@ivar fileno: the file descriptor associated with the tunnel
@type fileno: L{int}

@ivar name: the name of the tunnel
@type name: L{bytes}
r   N)r    r!   r"   r#   r$   r1   r   r2   r3   rV   rV   �   s   † õr2   rV   zfileno namec                   ó†   a € ] tR t^�t o Rt]! R4      t]! R4      t]! R4      tRR lt	RR lt
R tR	 tR
 tR tR tRtV tR# )Ú_IInputOutputSystemzŠ
An interface for performing some basic kinds of I/O (particularly that I/O
which might be useful for L{twisted.pair.tuntap}-using code).
z@see: L{os.O_RDWR}z@see: L{os.O_NONBLOCK}z@see: L{os.O_CLOEXEC}c                ó   € R# )z
@see: L{os.open}
Nr   )Úfilenamer9   Úmodes   &&&r3   ÚopenÚ_IInputOutputSystem.open—   ó   ‚ r2   Nc                ó   € R# )z
@see: L{fcntl.ioctl}
Nr   )ÚfdÚoptÚargÚmutate_flags   &&&&r3   ÚioctlÚ_IInputOutputSystem.ioctlœ   r^   r2   c                ó   € R# )z
@see: L{os.read}
Nr   )r`   Úlimits   &&r3   ÚreadÚ_IInputOutputSystem.read¡   r^   r2   c                ó   € R# )z
@see: L{os.write}
Nr   )r`   Údatas   &&r3   ÚwriteÚ_IInputOutputSystem.write¦   r^   r2   c                ó   € R# )z
@see: L{os.close}
Nr   )r`   s   &r3   ÚcloseÚ_IInputOutputSystem.close«   r^   r2   c                ó   € R# )aL  
Send a datagram to a certain address.

@param datagram: The payload of a UDP datagram to send.
@type datagram: L{bytes}

@param address: The destination to which to send the datagram.
@type address: L{tuple} of (L{bytes}, L{int})

@return: The local address from which the datagram was sent.
@rtype: L{tuple} of (L{bytes}, L{int})
Nr   )ÚdatagramÚaddresss   &&r3   ÚsendUDPÚ_IInputOutputSystem.sendUDP°   r^   r2   c                ó   € R# )aþ  
Return a socket which can be used to receive datagrams sent to the
given address.

@param fileno: A file descriptor representing a tunnel device which the
    datagram was either sent via or will be received via.
@type fileno: L{int}

@param host: The IPv4 address at which the datagram will be received.
@type host: L{bytes}

@param port: The UDP port number at which the datagram will be
    received.
@type port: L{int}

@return: A L{socket.socket} which can be used to receive the specified
    datagram.
Nr   )ÚfilenoÚhostÚports   &&&r3   Ú
receiveUDPÚ_IInputOutputSystem.receiveUDP¾   r^   r2   r   )iÿ  )NN)r    r!   r"   r#   r$   r   ÚO_RDWRÚ
O_NONBLOCKÚ	O_CLOEXECr\   rd   rh   rl   ro   rt   rz   r1   rR   rS   s   @r3   rX   rX   �   sU   ø‡ € ññ
 Ð+Ó,€FÙÐ3Ó4€JÙÐ1Ó2€Iôô
ò
ò
ò
ò
÷ð r2   rX   c                   ó  € ] tR t^ÓtRt]! ]P                  4      t]! ]P                  4      t]! ]P                  4      t	]! ]P                  4      t
]! ]P                  4      t]P                  t]P                  t]! ]RR4      tRtR# )Ú_RealSystemz�
An interface to the parts of the operating system which L{TuntapPort}
relies on.  This is most of an implementation of L{_IInputOutputSystem}.
r~   i   r   N)r    r!   r"   r#   r$   ÚstaticmethodÚosr\   rh   rl   ro   Úfcntlrd   r|   r}   Úgetattrr~   r1   r   r2   r3   r€   r€   Ó   sq   † ññ
 ˜Ÿ™Ó €DÙ˜Ÿ™Ó €DÙ˜Ÿ™Ó"€EÙ˜Ÿ™Ó"€EÙ˜Ÿ™Ó%€Eà�Y‰Y€FØ—‘€Jñ ˜˜K¨Ó3„Ir2   r€   c                   óº   a € ] tR t^æt o RtRtRR ltV 3R lR ltR tR t	R t
R	 tR
 tR tR tR t]! ]! R^^ ^ 4      ]4      R 4       tRR ltR tR tRtV tR# )r   z@
A Port that reads and writes packets from/to a TUN/TAP-device.
Nc                ó  € \         P                  P                  V4      '       d   ^V n         \        P                  V n        MC^ V n         \        P                  V n        \        P                  P                  V4      '       g   Q hVf   \        4       pWPn
        \        P                  P                  W4       Wn        W n        W0n        V P#                  V P                  4      pV RV P
                  P$                   R2V n        R# )é   Nz (Ú))r   ÚIEthernetProtocolÚ
providedByr   r&   Ú_moder%   r   ÚIRawPacketProtocolr€   Ú_systemr
   ÚFileDescriptorrC   Ú	interfaceÚprotocolÚmaxPacketSizeÚ_getLogPrefixr5   Úlogstr)r?   r�   Úprotor‘   ÚreactorÚsystemÚ	logPrefixs   &&&&&& r3   rC   ÚTuntapPort.__init__î   sÄ   € Ü×%Ñ%×0Ñ0°×7Ò7ØˆDŒMÜ$×,Ñ,ˆD�JàˆDŒMÜ$×,Ñ,ˆDŒJÜ×)Ñ)×4Ñ4°U×;Ò;Ð;Ð;àŠ>Ü “]ˆFØŒä×Ñ×(Ñ(¨Ô7Ø"ŒØŒØ*Ôà×&Ñ& t§}¡}Ó5ˆ	Ø"˜ 2 d§j¡j§o¡oÐ%6°aÐ8ˆŽr2   c                ó    <€ V ^8„  d   QhRS[ /# )é   Úreturn)Ústr)ÚformatrT   s   "€r3   Ú__annotate__ÚTuntapPort.__annotate__  s   ø€ ÷ 2ñ 2™#ñ 2r2   c                óî   € \        V P                  P                  4      3pV P                  '       d   VR,           pM	VR,           pWP                  P
                  V P                  3,           pRV,          # )Ú z<%s %slistening on %s/%s>)r¡   )znot )r   r�   Ú	__class__Ú	connectedr‹   r5   r�   )r?   Úargss   & r3   Ú__repr__ÚTuntapPort.__repr__  sY   € Ü!3°D·M±M×4KÑ4KÓ!LÐ NˆØ�>�>ˆ>Ø˜%•<‰Dà˜)Õ#ˆDØ—z‘z—‘¨¯©Ð7Õ7ˆØ*¨TÕ1Ð1r2   c                ó|   € V P                  4        V P                  P                  V 4       V P                  4        R# )z�
Create and bind my socket, and begin listening on it.

This must be called after creating a server to begin listening on the
specified tunnel.
N)Ú_bindSocketr�   ÚmakeConnectionÚstartReadingr>   s   &r3   ÚstartListeningÚTuntapPort.startListening  s.   € ð 	×ÑÔØ�‰×$Ñ$ TÔ*Ø×ÑÖr2   c                ó¸  € V P                   P                  V P                   P                  ,          V P                   P                  ,          p\        P
                  ! R\        3,          WP                  4      pV P                   P                  \        V4      pV P                   P                  V\        V4      p\        WVR\         P                  R4      4      # )a.  
Open the named tunnel using the given mode.

@param name: The name of the tunnel to open.
@type name: L{bytes}

@param mode: Flags from L{TunnelFlags} with exactly one of
    L{TunnelFlags.IFF_TUN} or L{TunnelFlags.IFF_TAP} set.

@return: A L{_TunnelDescription} representing the newly opened tunnel.
z%dsHNó    )r�   r|   r~   r}   ÚstructÚpackÚ	_IFNAMSIZr=   r\   Ú_TUN_KO_PATHrd   Ú
_TUNSETIFFrV   Ústrip)r?   r5   r[   ÚflagsÚconfigrw   Úresults   &&&    r3   Ú_openTunnelÚTuntapPort._openTunnel  s—   € ð —‘×#Ñ# d§l¡l×&<Ñ&<Õ<¸t¿|¹|×?VÑ?VÕVˆÜ—’˜V¤y lÕ2°D¿*¹*ÓEˆØ—‘×"Ñ"¤<°Ó7ˆØ—‘×#Ñ# F¬J¸Ó?ˆÜ! &°´)Ð*<×*BÑ*BÀ7Ó*KÓLÐLr2   c                ó€  € \         P                  ! RV P                  P                  V P                  R7        V P                  V P                  V P                  \        P                  ,          4      w  rY n        Yn        ^T n        R#   \         d(   p\        P                  ! RT P                  T4      hRp?ii ; i)z
Open the tunnel.
z&%(protocol)s starting on %(interface)s)r�   r�   r�   N)r   Úmsgr�   r¢   r�   r¸   r‹   r   r-   ÚOSErrorr   ÚCannotListenErrorÚ_filenor£   )r?   rw   r�   Úes   &   r3   r¨   ÚTuntapPort._bindSocket)  s˜   € ô 	�ŠØ;Ø—]‘]×,Ñ,Ø—n‘nõ	
ð
	CØ $× 0Ñ 0Ø—‘ §
¡
¬[×-BÑ-BÕ Bó!ÑˆFð #ŒØŒàˆŽøô ô 	CÜ×)Ò)¨$°·±ÀÓBÐBûð	Cús   ¹=B ÂB=Â"B8Â8B=c                ó   € V P                   # r8   )r¾   r>   s   &r3   rw   ÚTuntapPort.fileno>  s   € Ø�|‰|Ðr2   c                óP  € ^ pWP                   8  dd    V P                  P                  V P                  V P                  4      pT\        T4      ,          p T P                  P                  T^ R7       Ks  R#   \
         dK   pTP                  \        P                  \        P                  \        P                  39   d    Rp?R# h Rp?i\         d    h i ; i  \         d@    \        T P                  P                  4      p\         P"                  ! RRT R24        EK!  i ; i)z-
Called when my socket is ready for reading.
N)ÚpartialzUnhandled exception from z.datagramReceived)ÚmaxThroughputr�   rh   r¾   r‘   r¼   ÚerrnoÚEWOULDBLOCKÚEAGAINÚEINTRÚBaseExceptionÚlenr�   ÚdatagramReceivedr   r¢   r   Úerr)r?   rh   rk   r¿   Úclss   &    r3   ÚdoReadÚTuntapPort.doReadA  sò   € ð ˆØ×'Ñ'Ô'ðØ—|‘|×(Ñ(¨¯©°t×7IÑ7IÓJ�ð ”C˜“IÕˆDðRØ—‘×.Ñ.¨t¸QÐ.Ö?ñ (øô ô Ø—7‘7œu×0Ñ0´%·,±,ÄÇÁÐLÔLÝàûÜ ô Øðûô !ô RÜ(¨¯©×)@Ñ)@ÓA�Ü—’˜Ð 9¸#¸Ð>OÐP×QÐQðRús6   ”0A8 ÁC Á8CÂ>CÃCÃCÃCÃAD%Ä$D%c                óâ   €  V P                   P                  V P                  V4      #   \         d<   pTP                  \        P
                  8X  d   T P                  T4      u Rp?# h Rp?ii ; i)z›
Write the given data as a single datagram.

@param datagram: The data that will make up the complete datagram to be
    written.
@type datagram: L{bytes}
N)r�   rl   r¾   r¼   rÆ   rÉ   )r?   rr   r¿   s   && r3   rl   ÚTuntapPort.writeX  sT   € ð	Ø—<‘<×%Ñ% d§l¡l°HÓ=Ð=øÜô 	Ø�w‰wœ%Ÿ+™+Ô%Ø—z‘z (Ó+Õ+Øûð	ús    ‚%( ¨A.³/A)Á"A.Á(A)Á)A.c                óF   € V P                  RP                  V4      4       R# )zª
Write a datagram constructed from a L{list} of L{bytes}.

@param seq: The data that will make up the complete datagram to be
    written.
@type seq: L{list} of L{bytes}
r2   N)rl   Újoin)r?   Úseqs   &&r3   ÚwriteSequenceÚTuntapPort.writeSequenceg  s   € ð 	�
‰
�3—8‘8˜C“=Ö!r2   c                ó6  € V P                  4        V P                  '       d   V P                  # V P                  '       dE   \        P
                  ! V P                  ^ V P                  4      V n        RV n        V P                  # \        P                  ! R4      # )z¨
Stop accepting connections on this port.

This will shut down my socket and call self.connectionLost().

@return: A L{Deferred} that fires when this port has stopped.
TN)
ÚstopReadingÚdisconnectingÚ_stoppedDeferredr£   r   Ú
deferLaterr•   ÚconnectionLostr   Úsucceedr>   s   &r3   ÚstopListeningÚTuntapPort.stopListeningq  sx   € ð 	×ÑÔØ××ÐØ×(Ñ(Ð(Ø�^�^ˆ^Ü$(§O¢OØ—‘˜a ×!4Ñ!4ó%ˆDÔ!ð "&ˆDÔØ×(Ñ(Ð(ä—=’= Ó&Ð&r2   ÚTwistedc                ó`   € V P                  4       P                  \        P                  4       R# )z>
Close this tunnel.  Use L{TuntapPort.stopListening} instead.
N)rß   Ú
addErrbackr   rÍ   r>   s   &r3   ÚloseConnectionÚTuntapPort.loseConnection…  s   € ð
 	×ÑÓ×'Ñ'¬¯©Ö0r2   c                ó,  € \         P                  ! RV P                  ,          4       \        P                  P                  W4       V P                  P                  4        ^ V n        V P                  P                  V P                  4       RV n        R# )zA
Cleans up my socket.

@param reason: Ignored.  Do not use this.
z(Tuntap %s Closed)Néÿÿÿÿ)r   r»   r�   r
   rŽ   rÝ   r�   ÚdoStopr£   r�   ro   r¾   )r?   Úreasons   &&r3   rÝ   ÚTuntapPort.connectionLostŒ  sb   € ô 	�ŠÐ$ t§~¡~Õ5Ô6Ü×Ñ×.Ñ.¨tÔ<Ø�‰×ÑÔØˆŒØ�‰×Ñ˜4Ÿ<™<Ô(ØˆŽr2   c                ó   € V P                   # )z;
Returns the name of my class, to prefix log entries with.
)r“   r>   s   &r3   r—   ÚTuntapPort.logPrefix™  s   € ð �{‰{Ðr2   c                óB   € \        V P                  V P                  4      # )z©
Get the local address of this L{TuntapPort}.

@return: A L{TunnelAddress} which describes the tunnel device to which
    this object is bound.
@rtype: L{TunnelAddress}
)r   r‹   r�   r>   s   &r3   ÚgetHostÚTuntapPort.getHostŸ  s   € ô ˜TŸZ™Z¨¯©Ó8Ð8r2   )r¾   r‹   rÛ   r�   r£   rÚ   r   r�   r“   r‘   r�   i   )r   NNr8   )r    r!   r"   r#   r$   rÅ   rC   r¥   r«   r¸   r¨   rw   rÏ   rl   rÖ   rß   r   r	   rä   rÝ   r—   rî   r1   rR   rS   s   @r3   r   r   æ   s„   ø‡ € ñð €Mô9÷*2ð 2ò	òMò$ò*òRò.ò"ò'ñ( ‘˜	 2 q¨!Ó,¨mÓ<ñ1ó =ð1ôò÷9ð 9r2   )r   r   r   )6r$   rÆ   rƒ   r‚   Úplatformr¯   rI   Úcollectionsr   Útypingr   Úzope.interfacer   r   r   Ú
constantlyr   r   Úincrementalr	   Útwisted.internetr
   r   r   r   r   Útwisted.pairr   r   Útwisted.pythonr   Útwisted.python.deprecater   Útwisted.python.reflectr   Útwisted.python.utilr   r   Ú__all__r±   ÚmachineÚ
startswithr³   Ú
_TUNGETIFFr²   r   ÚIAddressr   rV   rX   r€   ÚIListeningPortrŽ   r   r   r2   r3   Ú<module>r     sE  ðñ
ó Û Û 	Û Û Û Ý "Ý ç <Ñ <ç *Ý ç EÕ Eß &Ý Ý /Ý 5ß ;ò€ð €	à×ÒÓ˜(Ô"Ø×ÒÓ×$Ñ$ U×+Ò+Ø×ÒÓ×$Ñ$ W×-Ò-ð €JØ�Jà€JØ€JØ€ô(�%ô (ñB ˆZ× Ñ Ó!ô&,�M <ó &,ó "ð&,ôR	™Ð$8¸-ÓHô 	ôC˜)ô C÷L4ñ 4ñ& ˆZ×&Ñ&Ó'ô@9�×(Ñ(ó @9ó (ò@9r2   