repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
XX-Net | code/default/x_tunnel/local/cloudfront_front/config.py | .py |
from front_base.config import ConfigBase
class Config(ConfigBase):
def __init__(self, fn):
super(Config, self).__init__(fn)
# front
self.set_var("front_continue_fail_num", 10)
self.set_var("front_continue_fail_block", 180)
# http_dispatcher
self.set_var("dispathe... | 40 | 1,175 |
XX-Net | code/default/x_tunnel/local/cloudfront_front/test.py | .py | #!/usr/bin/env python2
# coding:utf-8
import os
import sys
import time
import threading
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, os.pardir))
python_path = root_path
sys.path.append(root_path)
noarch_lib = os.path.abspath(... | 66 | 1,840 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/host_manager.py | .py | import os
import json
import utils
from front_base.host_manager import HostManagerBase
class HostManager(HostManagerBase):
def __init__(self, config_fn):
self.config_fn = config_fn
self.info = {}
self.load()
def load(self):
if not os.path.isfile(self.config_fn):
r... | 55 | 1,138 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/front.py | .py | import os
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir))
import xlog
import env_info
from .config import Config
from . import host_manager
from . import connect_creator
from . import ip_manager
from front_base.openssl_... | 141 | 4,627 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/http2_stream.py | .py |
from front_base.http2_stream import Stream as StreamBase
from front_base.http2_stream import STATE_OPEN
from hyper.packages.hyperframe.frame import (
FRAME_MAX_LEN, HeadersFrame
)
from hyper.common.util import to_native_string
class Stream(StreamBase):
def start_request(self):
"""
Open the... | 75 | 2,727 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/check_ip.py | .py | #!/usr/bin/env python
# coding:utf-8
import sys
import os
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, os.pardir))
python_path = root_path
sys.path.append(root_path)
noarch_lib = os.path.abspath( os.path.join(python_path, 'l... | 94 | 2,782 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/web_control.py | .py | #!/usr/bin/env python
# coding:utf-8
import os
import time
try:
from urllib.parse import urlparse, parse_qs
except ImportError:
from urlparse import urlparse, parse_qs
import simple_http_server
from .front import front
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(o... | 155 | 5,887 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/connect_creator.py | .py | import os
import socket
import struct
import time
import socks
import utils
import front_base.openssl_wrap
from front_base.connect_creator import ConnectCreator as ConnectCreatorBase
class ConnectCreator(ConnectCreatorBase):
def connect_ssl(self, ip_str, sni, host, close_cb=None):
info = self.host_man... | 75 | 2,897 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/config.py | .py |
from front_base.config import ConfigBase
class Config(ConfigBase):
def __init__(self, fn):
super(Config, self).__init__(fn)
# front
self.set_var("front_continue_fail_num", 10)
self.set_var("front_continue_fail_block", 10)
self.set_var("allow_set_ips", 1)
# https_... | 36 | 1,128 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/test.py | .py | #!/usr/bin/env python2
# coding:utf-8
import os
import sys
import time
current_path = os.path.dirname(os.path.abspath(__file__))
front_path = os.path.abspath( os.path.join(current_path, os.pardir))
root_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, os.pardir))
python_path = root_path
sys.p... | 66 | 1,932 |
XX-Net | code/default/x_tunnel/local/tls_relay_front/ip_manager.py | .py | import time
import json
import utils
from front_base.ip_manager import IpManagerBase
class IpManager(IpManagerBase):
def __init__(self, config, host_manager, logger, speed_fn):
super(IpManager, self).__init__(config, None, logger, speed_fn)
self.host_manager = host_manager
self.ip_dict = ... | 106 | 3,382 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/front.py | .py | import os
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir))
import env_info
import xlog
from .config import Config
from . import ip_manager
from front_base.openssl_wrap import SSLContext
from front_base.connect_creator i... | 136 | 5,002 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/check_ip.py | .py | #!/usr/bin/env python3
# coding:utf-8
import sys
import os
import threading
import json
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, os.pardir))
local_path = os.path.abspath( os.path.join(current_path, os.pardir))
import env_inf... | 188 | 5,563 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/web_control.py | .py | #!/usr/bin/env python
# coding:utf-8
import os
import time
try:
from urllib.parse import urlparse, parse_qs
except ImportError:
from urlparse import urlparse, parse_qs
import simple_http_server
from .front import front
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(o... | 154 | 5,759 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/http2_connection.py | .py | import utils
from front_base.http2_connection import Http2Worker
class CloudflareHttp2Worker(Http2Worker):
def __init__(self, logger, ip_manager, config, ssl_sock, close_cb, retry_task_cb, idle_cb, log_debug_data,
stream_class=None):
super(CloudflareHttp2Worker, self).__init__(
... | 18 | 671 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/config.py | .py |
from front_base.config import ConfigBase
class Config(ConfigBase):
def __init__(self, fn):
super(Config, self).__init__(fn)
# front
self.set_var("front_continue_fail_num", 10)
self.set_var("front_continue_fail_block", 20 * 60)
# http_dispatcher
self.set_var("disp... | 50 | 1,597 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/test.py | .py | #!/usr/bin/env python2
# coding:utf-8
import os
import sys
import time
import utils
current_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir))
python_path = root_path
sys.path.append(root_path)
noarch_lib = os.path.abspath(os.p... | 77 | 2,361 |
XX-Net | code/default/x_tunnel/local/cloudflare_front/ip_manager.py | .py | import os
import json
import socket
import time
import utils
from front_base.ip_manager import IpManagerBase
class IpManager(IpManagerBase):
def __init__(self, config, default_domain_fn, domain_fn, speed_fn, logger):
super(IpManager, self).__init__(config, None, logger, speed_fn)
self.default_do... | 139 | 4,607 |
XX-Net | code/default/x_tunnel/tests/test_proxy.py | .py | from unittest import TestCase
import json
import os
import time
import sys
current_path = os.path.dirname(os.path.abspath(__file__))
default_path = os.path.abspath(os.path.join(current_path, os.path.pardir, os.path.pardir))
root_path = os.path.abspath(os.path.join(default_path, os.path.pardir, os.path.pardir))
noarch... | 130 | 5,103 |
XX-Net | code/default/lib/noarch/subj_alt_name.py | .py | """NDG HTTPS Client package
Use pyasn1 to provide support for parsing ASN.1 formatted subjectAltName
content for SSL peer verification. Code based on:
http://stackoverflow.com/questions/5519958/how-do-i-parse-subjectaltname-extension-data-using-pyasn1
"""
__author__ = "P J Kershaw"
__date__ = "01/02/12"
__copyright_... | 154 | 6,131 |
XX-Net | code/default/lib/noarch/socks.py | .py | """
SocksiPy - Python SOCKS module.
Version 1.5.1
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | 805 | 30,141 |
XX-Net | code/default/lib/noarch/six.py | .py | # Copyright (c) 2010-2020 Benjamin Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publi... | 999 | 34,549 |
XX-Net | code/default/lib/noarch/utils.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import threading
from functools import reduce
from six import string_types
ipv4_pattern = re.compile(br'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$')
ipv6_pattern = re.compile(br"""
^
\s* # Leading whitespace
... | 366 | 9,976 |
XX-Net | code/default/lib/noarch/os_platform.py | .py | import sys
import os
current_path = os.path.dirname(os.path.abspath(__file__))
default_path = os.path.abspath(os.path.join(current_path, os.pardir))
has_desktop = False
if sys.platform.startswith("linux"):
if os.path.isfile("/system/bin/dalvikvm") or os.path.isfile("/system/bin/dalvikvm64"):
platform = "... | 24 | 581 |
XX-Net | code/default/lib/noarch/xx_six.py | .py | from six import PY2
if PY2:
class BlockingIOError(Exception):
pass
class BrokenPipeError(Exception):
pass
class ConnectionError(Exception):
pass
class ConnectionResetError(Exception):
pass
class ConnectionAbortedError(Exception):
pass
else:
BlockingIOError = Blockin... | 29 | 505 |
XX-Net | code/default/lib/noarch/xconfig.py | .py |
import time
import json
import os
import xlog
class Config(object):
def __init__(self, config_path):
self.last_load_time = time.time()
self.default_config = {}
self.file_config = {}
self.config_path = config_path
self.set_default()
def set_default(self):
pass
... | 59 | 2,066 |
XX-Net | code/default/lib/noarch/env_info.py | .py | import os
import platform
import sys
from pathlib import Path
import json
import utils
current_path = os.path.dirname(os.path.abspath(__file__))
default_path = os.path.abspath(os.path.join(current_path, os.path.pardir, os.path.pardir))
data_path = os.path.abspath(os.path.join(default_path, os.path.pardir, os.path.par... | 208 | 6,636 |
XX-Net | code/default/lib/noarch/lru_cache.py | .py | import collections
import json
import threading
class LruCache(object):
def __init__(self, capacity=3000):
self.capacity = capacity
self.cache = collections.OrderedDict()
self.lock = threading.Lock()
self.running = True
def get(self, key):
with self.lock:
... | 60 | 1,563 |
XX-Net | code/default/lib/noarch/simple_http_client.py | .py |
import selectors2 as selectors
from xlog import getLogger
xlog = getLogger("simple_http_client")
try:
# py3
from urllib.parse import urlparse, urlsplit
from http.client import IncompleteRead
except ImportError:
# py2
from urlparse import urlparse, urlsplit
from httplib import IncompleteRead
i... | 581 | 18,186 |
XX-Net | code/default/lib/noarch/xstruct.py | .py | from struct import pack
from struct import unpack as origin_unpack
need_convert = False
def unpack(format, data):
global need_convert
if need_convert and isinstance(data, memoryview):
data = data.tobytes()
try:
return origin_unpack(format, data)
except:
need_convert = True
... | 20 | 393 |
XX-Net | code/default/lib/noarch/simple_http_server.py | .py | import os
import datetime
import threading
import socket
import errno
import sys
import select
import time
import json
import base64
import hashlib
import struct
try:
from urllib.parse import urlparse, urlencode, parse_qs
from urllib.request import urlopen, Request
from urllib.error import HTTPError
except... | 784 | 28,626 |
XX-Net | code/default/lib/noarch/selectors2.py | .py | """ Back-ported, durable, and portable selectors """
# MIT License
#
# Copyright (c) 2017 Seth Michael Larson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including... | 786 | 29,711 |
XX-Net | code/default/lib/noarch/simple_queue.py | .py | import time
import threading
import sys
# This simple Queue fix the performance problem in the system build-in Queue.
# Every get with time out will run in thread sleep check sleep check...
# cost too many CPU and delay queue response.
# This solution will run a thread to check timeout, default is 0.1 second.
# And m... | 164 | 4,016 |
XX-Net | code/default/lib/noarch/xlog.py | .py | import os
import sys
import time
from datetime import datetime
import traceback
import threading
import json
import shutil
from os.path import join
from six import string_types
import utils
CRITICAL = 50
FATAL = CRITICAL
ERROR = 40
WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
NOTSET = 0
# full_log set by server... | 403 | 12,727 |
XX-Net | code/default/lib/noarch/encrypt.py | .py | #!/usr/bin/env python
# Copyright (c) 2014 clowwindy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, me... | 194 | 5,974 |
XX-Net | code/default/lib/noarch/ecdsa/numbertheory.py | .py | #! /usr/bin/env python
#
# Provide some simple capabilities from number theory.
#
# Version of 2008.11.14.
#
# Written in 2005 and 2006 by Peter Pearson and placed in the public domain.
# Revision history:
# 2008.11.14: Use pow(base, exponent, modulus) for modular_exp.
# Make gcd and lcm accept arbitrar... | 826 | 17,479 |
XX-Net | code/default/lib/noarch/ecdsa/errors.py | .py | class MalformedPointError(AssertionError):
"""Raised in case the encoding of private or public key is malformed."""
pass
| 5 | 130 |
XX-Net | code/default/lib/noarch/ecdsa/ellipticcurve.py | .py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Implementation of elliptic curves, for cryptographic applications.
#
# This module doesn't provide any way to choose a random elliptic
# curve, nor to verify that an elliptic curve was chosen randomly,
# because one can simply use NIST's standard curves.
#
# Notes from... | 1,585 | 53,625 |
XX-Net | code/default/lib/noarch/ecdsa/_compat.py | .py | """
Common functions for providing cross-python version compatibility.
"""
import sys
import re
import binascii
from six import integer_types
def str_idx_as_int(string, index):
"""Take index'th byte from string, return as integer"""
val = string[index]
if isinstance(val, integer_types):
return val... | 154 | 4,619 |
XX-Net | code/default/lib/noarch/ecdsa/ecdsa.py | .py | #! /usr/bin/env python
"""
Low level implementation of Elliptic-Curve Digital Signatures.
.. note ::
You're most likely looking for the :py:class:`~ecdsa.keys` module.
This is a low-level implementation of the ECDSA that operates on
integers, not byte strings.
NOTE: This a low level implementation of ECD... | 860 | 24,955 |
XX-Net | code/default/lib/noarch/ecdsa/util.py | .py | from __future__ import division
import os
import math
import binascii
import sys
from hashlib import sha256
from six import PY2, int2byte, b, next
from . import der
from ._compat import normalise_bytes
# RFC5480:
# The "unrestricted" algorithm identifier is:
# id-ecPublicKey OBJECT IDENTIFIER ::= {
# iso(... | 434 | 14,618 |
XX-Net | code/default/lib/noarch/ecdsa/_version.py | .py |
# This file was generated by 'versioneer.py' (0.21) from
# revision-control system data, or from the parent directory name of an
# unpacked source archive. Distribution tarballs contain a pre-generated copy
# of this file.
import json
version_json = '''
{
"date": "2022-07-09T14:49:17+0200",
"dirty": false,
"error... | 22 | 498 |
XX-Net | code/default/lib/noarch/ecdsa/__init__.py | .py | # while we don't use six in this file, we did bundle it for a long time, so
# keep as part of module in a virtual way (through __all__)
import six
from .keys import (
SigningKey,
VerifyingKey,
BadSignatureError,
BadDigestError,
MalformedPointError,
)
from .curves import (
NIST192p,
NIST224p,... | 91 | 1,637 |
XX-Net | code/default/lib/noarch/ecdsa/keys.py | .py | """
Primary classes for performing signing and verification operations.
"""
import binascii
from hashlib import sha1
import os
from six import PY2, b
from . import ecdsa, eddsa
from . import der
from . import rfc6979
from . import ellipticcurve
from .curves import NIST192p, Curve, Ed25519, Ed448
from .ecdsa import RSZ... | 1,613 | 65,124 |
XX-Net | code/default/lib/noarch/ecdsa/eddsa.py | .py | """Implementation of Edwards Digital Signature Algorithm."""
import hashlib
from ._sha3 import shake_256
from . import ellipticcurve
from ._compat import (
remove_whitespace,
bit_length,
bytes_to_int,
int_to_bytes,
compat26_str,
)
# edwards25519, defined in RFC7748
_p = 2**255 - 19
_a = -1
_d = in... | 253 | 7,170 |
XX-Net | code/default/lib/noarch/ecdsa/der.py | .py | from __future__ import division
import binascii
import base64
import warnings
from itertools import chain
from six import int2byte, b, text_type
from ._compat import str_idx_as_int
class UnexpectedDER(Exception):
pass
def encode_constructed(tag, value):
return int2byte(0xA0 + tag) + encode_length(len(value... | 410 | 14,109 |
XX-Net | code/default/lib/noarch/ecdsa/curves.py | .py | from __future__ import division
from six import PY2
from . import der, ecdsa, ellipticcurve, eddsa
from .util import orderlen, number_to_string, string_to_number
from ._compat import normalise_bytes, bit_length
# orderlen was defined in this module previously, so keep it in __all__,
# will need to mark it as depreca... | 514 | 14,390 |
XX-Net | code/default/lib/noarch/ecdsa/ecdh.py | .py | """
Class for performing Elliptic-curve Diffie-Hellman (ECDH) operations.
"""
from .util import number_to_string
from .ellipticcurve import INFINITY
from .keys import SigningKey, VerifyingKey
__all__ = [
"ECDH",
"NoKeyError",
"NoCurveError",
"InvalidCurveError",
"InvalidSharedSecretError",
]
cl... | 337 | 11,011 |
XX-Net | code/default/lib/noarch/ecdsa/_sha3.py | .py | """
Implementation of the SHAKE-256 algorithm for Ed448
"""
try:
import hashlib
hashlib.new("shake256").digest(64)
def shake_256(msg, outlen):
return hashlib.new("shake256", msg).digest(outlen)
except (TypeError, ValueError):
from ._compat import bytes_to_int, int_to_bytes
# From littl... | 182 | 4,747 |
XX-Net | code/default/lib/noarch/ecdsa/rfc6979.py | .py | """
RFC 6979:
Deterministic Usage of the Digital Signature Algorithm (DSA) and
Elliptic Curve Digital Signature Algorithm (ECDSA)
http://tools.ietf.org/html/rfc6979
Many thanks to Coda Hale for his implementation in Go language:
https://github.com/codahale/rfc6979
"""
import hmac
from binascii import... | 114 | 2,850 |
XX-Net | code/default/lib/noarch/ecdsa/_rwlock.py | .py | # Copyright Mateusz Kobos, (c) 2011
# https://code.activestate.com/recipes/577803-reader-writer-lock-with-priority-for-writers/
# released under the MIT licence
import threading
__author__ = "Mateusz Kobos"
class RWLock:
"""
Read-Write locking primitive
Synchronization object used in a solution of so-... | 87 | 2,849 |
XX-Net | code/default/lib/noarch/hyper/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyper
~~~~~~
A module for providing an abstraction layer over the differences between
HTTP/1.1 and HTTP/2.
"""
__version__ = '0.5.0'
from .common.connection import HTTPConnection
from .http20.connection import HTTP20Connection
from .http20.response import HTTP20Response, HTTP20Push
from .h... | 34 | 869 |
XX-Net | code/default/lib/noarch/hyper/tls.py | .py | # -*- coding: utf-8 -*-
"""
hyper/tls
~~~~~~~~~
Contains the TLS/SSL logic for use in hyper.
"""
import os.path as path
from .compat import ignore_missing, ssl
NPN_PROTOCOL = 'h2'
H2_NPN_PROTOCOLS = [NPN_PROTOCOL, 'h2-16', 'h2-15', 'h2-14']
SUPPORTED_NPN_PROTOCOLS = H2_NPN_PROTOCOLS + ['http/1.1']
H2C_PROTOCOL = '... | 95 | 3,030 |
XX-Net | code/default/lib/noarch/hyper/httplib_compat.py | .py | # -*- coding: utf-8 -*-
"""
hyper/httplib_compat
~~~~~~~~~~~~~~~~~~~~
This file defines the publicly-accessible API for hyper. This API also
constitutes the abstraction layer between HTTP/1.1 and HTTP/2.
This API doesn't currently work, and is a lower priority than the HTTP/2
stack at this time.
"""
import socket
try... | 117 | 4,468 |
XX-Net | code/default/lib/noarch/hyper/ssl_compat.py | .py | # -*- coding: utf-8 -*-
"""
hyper/ssl_compat
~~~~~~~~~
Shoves pyOpenSSL into an API that looks like the standard Python 3.x ssl module.
Currently exposes exactly those attributes, classes, and methods that we
actually use in hyper (all method signatures are complete, however). May be
expanded to something more genera... | 269 | 9,437 |
XX-Net | code/default/lib/noarch/hyper/contrib.py | .py | # -*- coding: utf-8 -*-
"""
hyper/contrib
~~~~~~~~~~~~~
Contains a few utilities for use with other HTTP libraries.
"""
try:
from requests.adapters import HTTPAdapter
from requests.models import Response
from requests.structures import CaseInsensitiveDict
from requests.utils import get_encoding_from_he... | 149 | 4,951 |
XX-Net | code/default/lib/noarch/hyper/compat.py | .py | # -*- coding: utf-8 -*-
"""
hyper/compat
~~~~~~~~~
Normalizes the Python 2/3 API for internal use.
"""
from contextlib import contextmanager
import sys
import zlib
try:
from . import ssl_compat
except ImportError:
# TODO log?
ssl_compat = None
_ver = sys.version_info
is_py2 = _ver[0] == 2
is_py2_7_9_or_l... | 82 | 1,726 |
XX-Net | code/default/lib/noarch/hyper/cli.py | .py | # -*- coding: utf-8 -*-
"""
hyper/cli
~~~~~~~~~
Command line interface for Hyper inspired by Httpie.
"""
import json
import locale
import logging
import sys
from argparse import ArgumentParser, RawTextHelpFormatter
from argparse import OPTIONAL, ZERO_OR_MORE
from pprint import pformat
from textwrap import dedent
from... | 257 | 7,440 |
XX-Net | code/default/lib/noarch/hyper/http11/parser.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http11/parser
~~~~~~~~~~~~~~~~~~~
This module contains hyper's pure-Python HTTP/1.1 parser. This module defines
an abstraction layer for HTTP/1.1 parsing that allows for dropping in other
modules if needed, in order to obtain speedups on your chosen platform.
"""
from collections impo... | 83 | 2,565 |
XX-Net | code/default/lib/noarch/hyper/http11/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http11
~~~~~~~~~~~~
The HTTP/1.1 submodule that powers hyper.
"""
| 8 | 101 |
XX-Net | code/default/lib/noarch/hyper/http11/connection.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http11/connection
~~~~~~~~~~~~~~~~~~~~~~~
Objects that build hyper's connection-level HTTP/1.1 abstraction.
"""
import logging
import os
import socket
import base64
try:
from collections import Iterable, Mapping
except:
from collections.abc import Iterable, Mapping
from .res... | 353 | 12,316 |
XX-Net | code/default/lib/noarch/hyper/http11/response.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http11/response
~~~~~~~~~~~~~~~~~~~~~
Contains the HTTP/1.1 equivalent of the HTTPResponse object defined in
httplib/http.client.
"""
import logging
import weakref
import zlib
from ..common.decoder import DeflateDecoder
from ..common.exceptions import ChunkedDecodeError, InvalidRespo... | 327 | 12,225 |
XX-Net | code/default/lib/noarch/hyper/packages/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyper/packages
~~~~~~~~~~~~~~
This module contains external packages that are vendored into hyper.
"""
| 8 | 132 |
XX-Net | code/default/lib/noarch/hyper/packages/hyperframe/frame.py | .py | # -*- coding: utf-8 -*-
"""
hyperframe/frame
~~~~~~~~~~~~~~~~
Defines framing logic for HTTP/2. Provides both classes to represent framed
data and logic for aiding the connection when it comes to reading from the
socket.
"""
import collections
import xstruct as struct
from .flags import Flag, Flags
from ...http20 imp... | 678 | 20,702 |
XX-Net | code/default/lib/noarch/hyper/packages/hyperframe/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyperframe
~~~~~~~~~~
A module for providing a pure-Python HTTP/2 framing layer.
"""
__version__ = '2.1.0'
| 9 | 136 |
XX-Net | code/default/lib/noarch/hyper/packages/hyperframe/flags.py | .py | # -*- coding: utf-8 -*-
"""
hyperframe/flags
~~~~~~~~~~~~~~~~
Defines basic Flag and Flags data structures.
"""
from collections import namedtuple
try:
from collections import MutableSet
except:
from collections.abc import MutableSet
Flag = namedtuple("Flag", ["name", "bit"])
class Flags(MutableSet):
"... | 47 | 1,192 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/normalizers.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 116 | 3,332 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/misc.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 215 | 7,880 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/exceptions.py | .py | # -*- coding: utf-8 -*-
class RFC3986Exception(Exception):
pass
class InvalidAuthority(RFC3986Exception):
def __init__(self, authority):
super(InvalidAuthority, self).__init__(
"The authority ({0}) is not valid.".format(authority))
class InvalidPort(RFC3986Exception):
def __init__(se... | 22 | 617 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 46 | 1,289 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/parseresult.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2015 Ian Cordasco
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 304 | 11,160 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/compat.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 32 | 928 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/api.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 93 | 3,383 |
XX-Net | code/default/lib/noarch/hyper/packages/rfc3986/uri.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 Rackspace
# Copyright (c) 2015 Ian Cordasco
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 386 | 14,669 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/table.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa
from collections import deque
import logging
from .exceptions import InvalidTableIndex
log = logging.getLogger(__name__)
def table_entry_size(name, value):
"""
Calculates the size of a single entry
This size is mostly irrelevant to us and defined
specifically ... | 216 | 8,950 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/exceptions.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/exceptions
~~~~~~~~~~~~~~~~~~~~~~~
This defines exceptions used in the HTTP/2 portion of hyper.
"""
class HPACKError(Exception):
"""
The base class for all ``hpack`` exceptions.
"""
pass
class HPACKDecodingError(HPACKError):
"""
An error has been enc... | 50 | 974 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/huffman_table.py | .py | # -*- coding: utf-8 -*-
"""
hpack/huffman_table
~~~~~~~~~~~~~~~~~~~
This implementation of a Huffman decoding table for HTTP/2 is essentially a
Python port of the work originally done for nghttp2's Huffman decoding. For
this reason, while this file is made available under the MIT license as is the
rest of this module,... | 4,740 | 168,580 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/hpack_compat.py | .py | # -*- coding: utf-8 -*-
"""
hpack/hpack_compat
~~~~~~~~~~~~~~~~~~
Provides an abstraction layer over two HPACK implementations.
This module has a pure-Python greenfield HPACK implementation that can be used
on all Python platforms. However, this implementation is both slower and more
memory-hungry than could be achie... | 108 | 3,602 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hpack
~~~~~
HTTP/2 header encoding for Python.
"""
from .hpack import Encoder, Decoder
from .struct import HeaderTuple, NeverIndexedHeaderTuple
from .exceptions import (
HPACKError, HPACKDecodingError, InvalidTableIndex, OversizedHeaderListError
)
__all__ = [
'Encoder', 'Decoder', ... | 21 | 479 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/struct.py | .py | # -*- coding: utf-8 -*-
"""
hpack/struct
~~~~~~~~~~~~
Contains structures for representing header fields with associated metadata.
"""
class HeaderTuple(tuple):
"""
A data structure that stores a single header field.
HTTP headers can be thought of as tuples of ``(field name, field value)``.
A single... | 40 | 1,052 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/huffman_constants.py | .py | # -*- coding: utf-8 -*-
"""
hpack/huffman_constants
~~~~~~~~~~~~~~~~~~~~~~~
Defines the constant Huffman table. This takes up an upsetting amount of space,
but c'est la vie.
"""
REQUEST_CODES = [
0x1ff8,
0x7fffd8,
0xfffffe2,
0xfffffe3,
0xfffffe4,
0xfffffe5,
0xfffffe6,
0xfffffe7,
0x... | 289 | 4,628 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/compat.py | .py | # -*- coding: utf-8 -*-
"""
hpack/compat
~~~~~~~~~~~~
Normalizes the Python 2/3 API for internal use.
"""
import sys
_ver = sys.version_info
is_py2 = _ver[0] == 2
is_py3 = _ver[0] == 3
if is_py2:
def to_byte(char):
return ord(char)
def decode_hex(b):
return b.decode('hex')
def to_bytes... | 43 | 667 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/huffman.py | .py | # -*- coding: utf-8 -*-
"""
hpack/huffman_decoder
~~~~~~~~~~~~~~~~~~~~~
An implementation of a bitwise prefix tree specially built for decoding
Huffman-coded content where we already know the Huffman table.
"""
from .compat import to_byte, decode_hex
class HuffmanEncoder(object):
"""
Encodes a string accordi... | 69 | 2,521 |
XX-Net | code/default/lib/noarch/hyper/packages/hpack/hpack.py | .py | # -*- coding: utf-8 -*-
"""
hpack/hpack
~~~~~~~~~~~
Implements the HPACK header compression algorithm as detailed by the IETF.
"""
import logging
from .table import HeaderTable, table_entry_size
from .compat import to_byte, to_bytes
from .exceptions import (
HPACKDecodingError, OversizedHeaderListError, InvalidTa... | 636 | 22,897 |
XX-Net | code/default/lib/noarch/hyper/common/exceptions.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common/exceptions
~~~~~~~~~~~~~~~~~~~~~~~
Contains hyper's exceptions.
"""
class ChunkedDecodeError(Exception):
"""
An error was encountered while decoding a chunked response.
"""
pass
class InvalidResponseError(Exception):
"""
A problem was found with the re... | 63 | 1,405 |
XX-Net | code/default/lib/noarch/hyper/common/util.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common/util
~~~~~~~~~~~~~~~~~
General utility functions for use with hyper.
"""
from hyper.compat import str, bytes, imap
from ..packages.rfc3986.uri import URIReference
from ..compat import is_py3
from six import string_types
def to_bytestring(element):
"""
Converts a singl... | 67 | 1,617 |
XX-Net | code/default/lib/noarch/hyper/common/headers.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common/headers
~~~~~~~~~~~~~~~~~~~~~
Contains hyper's structures for storing and working with HTTP headers.
"""
try:
from collections import MutableMapping
except:
from collections.abc import MutableMapping
from hyper.common.util import to_bytestring, to_bytestring_tuple
c... | 265 | 8,948 |
XX-Net | code/default/lib/noarch/hyper/common/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common
~~~~~~~~~~~~
Common code in hyper.
"""
| 8 | 81 |
XX-Net | code/default/lib/noarch/hyper/common/connection.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common/connection
~~~~~~~~~~~~~~~~~~~~~~~
Hyper's HTTP/1.1 and HTTP/2 abstraction layer.
"""
from .exceptions import TLSUpgrade, HTTPUpgrade
from ..http11.connection import HTTP11Connection
from ..http20.connection import HTTP20Connection
from ..tls import H2_NPN_PROTOCOLS, H2C_PROTOC... | 157 | 6,347 |
XX-Net | code/default/lib/noarch/hyper/common/decoder.py | .py | # -*- coding: utf-8 -*-
"""
hyper/common/decoder
~~~~~~~~~~~~~~~~~~~~
Contains hyper's code for handling compressed bodies.
"""
import zlib
class DeflateDecoder(object):
"""
This is a decoding object that wraps ``zlib`` and is used for decoding
deflated content.
This rationale for the existence of t... | 49 | 1,560 |
XX-Net | code/default/lib/noarch/hyper/common/bufsocket.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/bufsocket.py
~~~~~~~~~~~~~~~~~~~~~~~~~
This file implements a buffered socket wrapper.
The purpose of this is to avoid the overhead of unnecessary syscalls while
allowing small reads from the network. This represents a potentially massive
performance optimisation at the cost o... | 364 | 12,375 |
XX-Net | code/default/lib/noarch/hyper/http20/errors.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/errors
~~~~~~~~~~~~~~~~~~~
Global error code registry containing the established HTTP/2 error codes.
The registry is based on a 32-bit space so we use the error code to index into
the array.
The current registry is available at:
https://tools.ietf.org/html/rfc7540#section-11.4... | 76 | 3,238 |
XX-Net | code/default/lib/noarch/hyper/http20/exceptions.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/exceptions
~~~~~~~~~~~~~~~~~~~~~~~
This defines exceptions used in the HTTP/2 portion of hyper.
"""
class HTTP20Error(Exception):
"""
The base class for all of ``hyper``'s HTTP/2-related exceptions.
"""
pass
class HPACKEncodingError(HTTP20Error):
"""
... | 50 | 947 |
XX-Net | code/default/lib/noarch/hyper/http20/window.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/window
~~~~~~~~~~~~~~~~~~~
Objects that understand flow control in hyper.
HTTP/2 implements connection- and stream-level flow control. This flow
control is mandatory. Unfortunately, it's difficult for hyper to be
all that intelligent about how it manages flow control in a gene... | 151 | 6,122 |
XX-Net | code/default/lib/noarch/hyper/http20/util.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/util
~~~~~~~~~~~~~~~~~
Utility functions for use with hyper.
"""
from collections import defaultdict
def combine_repeated_headers(kvset):
"""
Given a list of key-value pairs (like for HTTP headers!), combines pairs
with the same key together, separating the values... | 57 | 1,592 |
XX-Net | code/default/lib/noarch/hyper/http20/__init__.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20
~~~~~~~~~~~~
The HTTP/2 submodule that powers hyper.
"""
| 8 | 99 |
XX-Net | code/default/lib/noarch/hyper/http20/connection.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/connection
~~~~~~~~~~~~~~~~~~~~~~~
Objects that build hyper's connection-level HTTP/2 abstraction.
"""
from ..tls import wrap_socket, H2_NPN_PROTOCOLS, H2C_PROTOCOL
from ..common.exceptions import ConnectionResetError
from ..common.bufsocket import BufferedSocket
from ..common.... | 775 | 30,392 |
XX-Net | code/default/lib/noarch/hyper/http20/response.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/response
~~~~~~~~~~~~~~~~~~~~~
Contains the HTTP/2 equivalent of the HTTPResponse object defined in
httplib/http.client.
"""
import logging
import zlib
from ..common.decoder import DeflateDecoder
from ..common.headers import HTTPHeaderMap
log = logging.getLogger(__name__)
d... | 228 | 7,930 |
XX-Net | code/default/lib/noarch/hyper/http20/stream.py | .py | # -*- coding: utf-8 -*-
"""
hyper/http20/stream
~~~~~~~~~~~~~~~~~~~
Objects that make up the stream-level abstraction of hyper's HTTP/2 support.
These objects are not expected to be part of the public HTTP/2 API: they're
intended purely for use inside hyper's HTTP/2 abstraction.
Conceptually, a single HTTP/2 connect... | 450 | 17,465 |
XX-Net | code/default/lib/noarch/pyasn1/error.py | .py | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
class PyAsn1Error(Exception):
"""Create pyasn1 exception object
The `PyAsn1Error` exception represents generic, usually fatal, error.
"""
class Va... | 30 | 709 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.