
    c                     h    S r SSKrSSKrSSKrSSKJr  SS/rS rSS/rS	 r	S
 r
S rS r  SS jrg)aL  
websocket - WebSocket client library for Python

Copyright (C) 2010 Hiroki Ohtani(liris)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1335  USA

    N)urlparse	parse_urlget_proxy_infoc                    SU ;  a  [        S5      eU R                  SS5      u  p[        U SS9nUR                  (       a  UR                  nO[        S5      eSnUR                  (       a  UR                  nSnUS:X  a
  U(       d  S	nO US
:X  a  SnU(       d  SnO[        SU-  5      eUR
                  (       a  UR
                  nOSnUR                  (       a  USUR                  -   -  nX4Xe4$ )zt
parse url and the result is tuple of
(hostname, port, resource path and the flag of secure mode)

url: url string.
:zurl is invalid   ws)schemezhostname is invalidr   FP   wssTi  zscheme %s is invalid/?)
ValueErrorsplitr   hostnameportpathquery)urlr
   parsedr   r   	is_secureresources          !lib/third_party/websocket/_url.pyr   r   !   s     #~)**))C#KFc$'F??.//D{{{{I~D	5	D/&899{{;;||C&,,&&8..    	localhostz	127.0.0.1c                 f     [         R                  " U 5        g! [         R                   a     gf = f)NTF)socket	inet_atonerror)addrs    r   _is_ip_addressr!   O   s2      << s    00c                      U R                  S5      u  p[        U5      =(       a    S[        U5      s=:*  =(       a    S:  $ s  $ ! [         a     gf = f)Nr   r       F)r   r!   intr   )r   r    netmasks      r   _is_subnet_addressr&   X   sP     s+d#>S\(>(>B(>>(>> s   ?A A 
AAc                    [         R                  " S[        R                  " U 5      5      S   nUR	                  S5      u  p4[         R                  " S[        R                  " U5      5      S   S[        U5      S-
  -  S-
  -  nX%-  U:H  $ )NIr   r      r   )structunpackr   r   r   r$   )ipnetipaddrnetaddrbitsr%   s         r   _is_address_in_networkr1   `   sx    ]]3 0 0 45a8FIIcNMGmmC!1!1'!:;A>1D	TUCUYZBZ[Gw&&r   c           	      R   U(       dA  [         R                  R                  SS5      R                  SS5      nUR	                  S5      nU(       d  [
        nX;   a  g[        U 5      (       a7  [        U Vs/ s H   n[        U5      (       d  M  [        X5      PM"     sn5      $ gs  snf )Nno_proxy  ,TF)
osenvirongetreplacer   DEFAULT_NO_PROXY_HOSTr!   anyr&   r1   )r   r3   vsubnets       r   _is_no_proxy_hostr?   g   s    JJNN:r*223;773<(		!	!8r8WijpWq<*8<8rss ss   5B$B$c                 ~   [        X5      (       a  gU(       a  UnUnX'U4$ S/n	U(       a  U	R                  SS5        U	 H{  n
[        R                  R	                  U
S5      nU(       d  M,  [        U5      nUR                  (       a  UR                  UR                  4OSnUR                  UR                  U4s  $    g)a  
try to retrieve proxy host and port from environment
if not provided in options.
result is (proxy_host, proxy_port, proxy_auth).
proxy_auth is tuple of username and password
 of proxy authentication information.

hostname: websocket server name.

is_secure:  is the connection secure? (wss)
            looks for "https_proxy" in env
            before falling back to "http_proxy"

options:    "http_proxy_host" - http proxy host name.
            "http_proxy_port" - http proxy port.
            "http_no_proxy"   - host names, which doesn't use proxy.
            "http_proxy_auth" - http proxy auth information.
                                tuple of username and password.
                                default is None
            "proxy_type"      - if set to "socks5" PySocks wrapper
                                will be used in place of a http proxy.
                                default is "http"
)Nr   N
http_proxyr   https_proxyN)
r?   insertr7   r8   r9   r   usernamepasswordr   r   )r   r   
proxy_host
proxy_port
proxy_authr3   
proxy_typer   authenv_keyskeyvalueproxys                r   r   r   v   s    4 ,,%%~H=)

sD)5UOE7<~~ENNENN34D>>5::t33  r   )Nr   NNhttp)__doc__r7   r   r*   six.moves.urllib.parser   __all__r   r;   r!   r&   r1   r?   r    r   r   <module>rT      s[   , 
   + (
)(/V %k2 '  HL"(-r   