Skip to content

Commit

Permalink
Merge branch 'master' into fix/NotImplementedError
Browse files Browse the repository at this point in the history
  • Loading branch information
bluet authored Dec 10, 2023
2 parents 312517e + dc944d6 commit 1baa1c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"aiodns",
"aiohttp",
"asyncio",
"fgroup",
"fparser",
"gparser",
"gunicorn",
"maxminddb",
"proxybroker",
"proxycontrol",
"Referer"
"Referer",
"uparser"
],
"esbonio.sphinx.confDir": "${workspaceFolder}/docs/source"
}
3 changes: 0 additions & 3 deletions proxybroker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import sys
from contextlib import contextmanager

import sys
import asyncio

if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Expand Down
5 changes: 4 additions & 1 deletion proxybroker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(self, host=None, port=None, types=(), timeout=8, verify_ssl=False):
'Try Proxy.create() if the host is a domain'
)

if port is None:
raise ValueError('The port of proxy cannot be None')

self.port = int(port)
if self.port > 65535:
raise ValueError('The port of proxy cannot be greater than 65535')
Expand Down Expand Up @@ -197,7 +200,7 @@ def avgRespTime(self):
Use :attr:`avg_resp_time` instead.
"""
warnings.warn(
'`avgRespTime` property is deprecated, ' 'use `avg_resp_time` instead.',
'`avgRespTime` property is deprecated, use `avg_resp_time` instead.',
DeprecationWarning,
)
return self.avg_resp_time
Expand Down
13 changes: 6 additions & 7 deletions proxybroker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
r'(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)'
)

IPv6Pattern = re.compile(
r'\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f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4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)).*?(?P<port>\d{2,5}).*$', # noqa
flags=re.MULTILINE,
Expand All @@ -33,14 +37,9 @@
flags=re.DOTALL,
)

# IsIpPattern = re.compile(
# r'^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$')


def get_headers(rv=False):
_rv = str(random.randint(1000, 9999)) if rv else ''
headers = {
# 'User-Agent': 'Mozilla/5.0 (X11; U; Linux i386; ru-RU; rv:2.0) Gecko/20100625 Firefox/3.5.11', # noqa
'User-Agent': 'PxBroker/%s/%s' % (version, _rv),
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
Expand All @@ -53,8 +52,8 @@ def get_headers(rv=False):


def get_all_ip(page):
# TODO: add IPv6 support
return set(IPPattern.findall(page))
# NOTE: IPv6 addresses support need to be tested
return set(IPPattern.findall(page) + IPv6Pattern.findall(page))


def get_status_code(resp, start=9, stop=12):
Expand Down

0 comments on commit 1baa1c9

Please sign in to comment.