Skip to content

Commit dc944d6

Browse files
committed
minor fixes
1 parent d14e305 commit dc944d6

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"aiodns",
55
"aiohttp",
66
"asyncio",
7+
"fgroup",
8+
"fparser",
9+
"gparser",
710
"gunicorn",
811
"maxminddb",
912
"proxybroker",
1013
"proxycontrol",
11-
"Referer"
14+
"Referer",
15+
"uparser"
1216
],
1317
"esbonio.sphinx.confDir": "${workspaceFolder}/docs/source"
1418
}

proxybroker/cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import sys
88
from contextlib import contextmanager
99

10-
import sys
11-
import asyncio
12-
1310
if sys.platform == 'win32':
1411
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
1512

proxybroker/proxy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def __init__(self, host=None, port=None, types=(), timeout=8, verify_ssl=False):
7272
'Try Proxy.create() if the host is a domain'
7373
)
7474

75+
if port is None:
76+
raise ValueError('The port of proxy cannot be None')
77+
7578
self.port = int(port)
7679
if self.port > 65535:
7780
raise ValueError('The port of proxy cannot be greater than 65535')
@@ -197,7 +200,7 @@ def avgRespTime(self):
197200
Use :attr:`avg_resp_time` instead.
198201
"""
199202
warnings.warn(
200-
'`avgRespTime` property is deprecated, ' 'use `avg_resp_time` instead.',
203+
'`avgRespTime` property is deprecated, use `avg_resp_time` instead.',
201204
DeprecationWarning,
202205
)
203206
return self.avg_resp_time

proxybroker/utils.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
r'(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)'
2323
)
2424

25+
IPv6Pattern = re.compile(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+
2529
IPPortPatternLine = re.compile(
2630
r'^.*?(?P<ip>(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)).*?(?P<port>\d{2,5}).*$', # noqa
2731
flags=re.MULTILINE,
@@ -33,14 +37,9 @@
3337
flags=re.DOTALL,
3438
)
3539

36-
# IsIpPattern = re.compile(
37-
# r'^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$')
38-
39-
4040
def get_headers(rv=False):
4141
_rv = str(random.randint(1000, 9999)) if rv else ''
4242
headers = {
43-
# 'User-Agent': 'Mozilla/5.0 (X11; U; Linux i386; ru-RU; rv:2.0) Gecko/20100625 Firefox/3.5.11', # noqa
4443
'User-Agent': 'PxBroker/%s/%s' % (version, _rv),
4544
'Accept': '*/*',
4645
'Accept-Encoding': 'gzip, deflate',
@@ -53,8 +52,8 @@ def get_headers(rv=False):
5352

5453

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

5958

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

0 commit comments

Comments
 (0)