
    'he                     x    d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlmZ	 d dl
mZ  G d d      Z G d d	      Zy)
    N)crypto)certs
exceptions)options)server_specc                   ,    e Zd Z e       fdZd Zd Zy)HostMatcherc                     || _         t        |      | _        | j                  D cg c]&  }t        j                  |t        j
                        ( c}| _        y c c}w N)handlelistpatternsrecompile
IGNORECASEregexes)selfr   r   ps       o/var/www/html/scrapers/gsc/venv/lib/python3.12/site-packages/seleniumwire/thirdparty/mitmproxy/server/config.py__init__zHostMatcher.__init__   s<    X>BmmL

1bmm4LLs   +Ac                     |syd|z  | j                   dv rt        fd| j                  D              S t        fd| j                  D               S )NFz%s:%s)ignoretcpc              3   @   K   | ]  }|j                          y wr   search.0rexhosts     r   	<genexpr>z'HostMatcher.__call__.<locals>.<genexpr>   s     @Cszz$'@   c              3   @   K   | ]  }|j                          y wr   r   r   s     r   r!   z'HostMatcher.__call__.<locals>.<genexpr>   s     D3::d+Dr"   )r   anyr   )r   addressr    s     @r   __call__zHostMatcher.__call__   sM     ;;++@4<<@@@Dt||DDDD    c                 ,    t        | j                        S r   )boolr   )r   s    r   __bool__zHostMatcher.__bool__   s    DMM""r'   N)__name__
__module____qualname__tupler   r&   r*    r'   r   r	   r	      s    (- M
E#r'   r	   c                   l    e Zd Zdej                  ddfdZdej                  dej                  ddfdZy)ProxyConfigr   returnNc                     || _         |  d | _        d | _        d | _        | j	                  |t        |j                                      |j                  j                  | j                         y r   )	r   check_filter	check_tcpupstream_server	configuresetkeyschangedconnect)r   r   s     r   r   zProxyConfig.__init__!   sR    :>7;HLwGLLN 34/r'   updatedc                    |j                   r!|j                  rt        j                  d      |j                  rt	        d|j                        | _        n8|j                   rt	        d|j                         | _        nt	        d      | _        d|v rt	        d|j                        | _        t        j                  j                  |j                        }t        j                  j                  t        j                  j                  |            s5t        j                  dt        j                  j                  |      z        |j                  }|j                  r|j                  j!                  d      nd }t"        j$                  j'                  |t(        j*                  ||      | _        |j"                  D ]  }|j/                  d	d
      }t1        |      d
k(  rd|d   g}t        j                  j                  |d
         }t        j                  j                  |      st        j                  d|z        	 | j,                  j3                  |d   ||        |j8                  }	|	j;                  d      s|	j;                  d      r*t=        j>                  |j8                        \  }
}|| _         y y # t4        j6                  $ r t        j                  d|z        w xY w)NzK--ignore-hosts and --allow-hosts are mutually exclusive; please choose one.r   allowF	tcp_hostsr   z9Certificate Authority parent directory does not exist: %szutf-8=   *r   z#Certificate file does not exist: %szInvalid certificate format: %sz	upstream:zreverse:)!allow_hostsignore_hostsr   OptionsErrorr	   r4   r?   r5   ospath
expanduserconfdirexistsdirnamekey_sizecert_passphraseencoder   	CertStore
from_storemoptionsCONF_BASENAME	certstoresplitlenadd_cert_filer   Errormode
startswithr   parse_with_moder6   )r   r   r<   certstore_pathrL   
passphrasecpartscertm_specs               r   r7   zProxyConfig.configure+   sa   7#7#7)) +J K K  +Hg6J6J KD   +GW5H5H ID +E 2D'!(0A0ABDN++GOO<ww~~bggoon=>))K/0  ##@G@W@WW,,33G<]a
33""	
  	AGGCOE5zQeAh77%%eAh/D77>>$' --9D@ ,,U1XtZH	  LL<<$Z(@!11',,?GAt#'D  )A <<  --4t; s    J<<,K()	r+   r,   r-   rQ   Optionsr   typingAnyr7   r/   r'   r   r1   r1      s?    0 0 0 0T 00(!1!1 0(FJJ 0(4 0(r'   r1   )rF   r   rd   OpenSSLr   !seleniumwire.thirdparty.mitmproxyr   r   r   rQ   %seleniumwire.thirdparty.mitmproxy.netr   r	   r1   r/   r'   r   <module>ri      s.    	 	   ? A =# #&<( <(r'   