mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Bump websocket-client from 1.6.2 to 1.7.0 (#2207)
* Bump websocket-client from 1.6.2 to 1.7.0 Bumps [websocket-client](https://github.com/websocket-client/websocket-client) from 1.6.2 to 1.7.0. - [Release notes](https://github.com/websocket-client/websocket-client/releases) - [Changelog](https://github.com/websocket-client/websocket-client/blob/master/ChangeLog) - [Commits](https://github.com/websocket-client/websocket-client/compare/v1.6.2...v1.7.0) --- updated-dependencies: - dependency-name: websocket-client dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update websocket-client==1.7.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
dbffb519f5
commit
24b6d37bbe
23 changed files with 1909 additions and 801 deletions
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import socket
|
||||
import struct
|
||||
|
||||
from typing import Optional
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
"""
|
||||
|
@ -67,7 +67,7 @@ def parse_url(url: str) -> tuple:
|
|||
resource = "/"
|
||||
|
||||
if parsed.query:
|
||||
resource += "?" + parsed.query
|
||||
resource += f"?{parsed.query}"
|
||||
|
||||
return hostname, port, resource, is_secure
|
||||
|
||||
|
@ -93,37 +93,50 @@ def _is_subnet_address(hostname: str) -> bool:
|
|||
|
||||
|
||||
def _is_address_in_network(ip: str, net: str) -> bool:
|
||||
ipaddr = struct.unpack('!I', socket.inet_aton(ip))[0]
|
||||
netaddr, netmask = net.split('/')
|
||||
netaddr = struct.unpack('!I', socket.inet_aton(netaddr))[0]
|
||||
ipaddr: int = struct.unpack("!I", socket.inet_aton(ip))[0]
|
||||
netaddr, netmask = net.split("/")
|
||||
netaddr: int = struct.unpack("!I", socket.inet_aton(netaddr))[0]
|
||||
|
||||
netmask = (0xFFFFFFFF << (32 - int(netmask))) & 0xFFFFFFFF
|
||||
return ipaddr & netmask == netaddr
|
||||
|
||||
|
||||
def _is_no_proxy_host(hostname: str, no_proxy: list) -> bool:
|
||||
def _is_no_proxy_host(hostname: str, no_proxy: Optional[list]) -> bool:
|
||||
if not no_proxy:
|
||||
v = os.environ.get("no_proxy", os.environ.get("NO_PROXY", "")).replace(" ", "")
|
||||
if v:
|
||||
if v := os.environ.get("no_proxy", os.environ.get("NO_PROXY", "")).replace(
|
||||
" ", ""
|
||||
):
|
||||
no_proxy = v.split(",")
|
||||
if not no_proxy:
|
||||
no_proxy = DEFAULT_NO_PROXY_HOST
|
||||
|
||||
if '*' in no_proxy:
|
||||
if "*" in no_proxy:
|
||||
return True
|
||||
if hostname in no_proxy:
|
||||
return True
|
||||
if _is_ip_address(hostname):
|
||||
return any([_is_address_in_network(hostname, subnet) for subnet in no_proxy if _is_subnet_address(subnet)])
|
||||
for domain in [domain for domain in no_proxy if domain.startswith('.')]:
|
||||
return any(
|
||||
[
|
||||
_is_address_in_network(hostname, subnet)
|
||||
for subnet in no_proxy
|
||||
if _is_subnet_address(subnet)
|
||||
]
|
||||
)
|
||||
for domain in [domain for domain in no_proxy if domain.startswith(".")]:
|
||||
if hostname.endswith(domain):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_proxy_info(
|
||||
hostname: str, is_secure: bool, proxy_host: str = None, proxy_port: int = 0, proxy_auth: tuple = None,
|
||||
no_proxy: list = None, proxy_type: str = 'http') -> tuple:
|
||||
hostname: str,
|
||||
is_secure: bool,
|
||||
proxy_host: Optional[str] = None,
|
||||
proxy_port: int = 0,
|
||||
proxy_auth: Optional[tuple] = None,
|
||||
no_proxy: Optional[list] = None,
|
||||
proxy_type: str = "http",
|
||||
) -> tuple:
|
||||
"""
|
||||
Try to retrieve proxy host and port from environment
|
||||
if not provided in options.
|
||||
|
@ -159,10 +172,16 @@ def get_proxy_info(
|
|||
return proxy_host, port, auth
|
||||
|
||||
env_key = "https_proxy" if is_secure else "http_proxy"
|
||||
value = os.environ.get(env_key, os.environ.get(env_key.upper(), "")).replace(" ", "")
|
||||
value = os.environ.get(env_key, os.environ.get(env_key.upper(), "")).replace(
|
||||
" ", ""
|
||||
)
|
||||
if value:
|
||||
proxy = urlparse(value)
|
||||
auth = (unquote(proxy.username), unquote(proxy.password)) if proxy.username else None
|
||||
auth = (
|
||||
(unquote(proxy.username), unquote(proxy.password))
|
||||
if proxy.username
|
||||
else None
|
||||
)
|
||||
return proxy.hostname, proxy.port, auth
|
||||
|
||||
return None, 0, None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue