Skip to content

Commit

Permalink
Merge pull request #16 from ShadowHunterRUS/patch-1
Browse files Browse the repository at this point in the history
Fix NameError: name 'ProxyConnector' is not defined
  • Loading branch information
Fahreeve authored Jun 19, 2017
2 parents 027eb46 + 8613de9 commit 85ee685
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions aiovk/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import aiosocks
from aiosocks.connector import ProxyConnector
except ImportError:
pass
ProxyConnector = None


class CustomClientResponse(aiohttp.ClientResponse):
Expand Down Expand Up @@ -95,16 +95,17 @@ def close(self):
self.session.close()


class Socks5Driver(HttpDriver):
connector = ProxyConnector

def __init__(self, address, port, login=None, password=None, timeout=10, loop=None):
super().__init__(timeout)
self.close()
addr = aiosocks.Socks5Addr(address, port)
if login and password:
auth = aiosocks.Socks5Auth(login, password=password)
else:
auth = None
conn = self.connector(proxy=addr, proxy_auth=auth, loop=loop)
self.session = aiohttp.ClientSession(connector=conn, response_class=CustomClientResponse)
if ProxyConnector is not None:
class Socks5Driver(HttpDriver):
connector = ProxyConnector

def __init__(self, address, port, login=None, password=None, timeout=10, loop=None):
super().__init__(timeout)
self.close()
addr = aiosocks.Socks5Addr(address, port)
if login and password:
auth = aiosocks.Socks5Auth(login, password=password)
else:
auth = None
conn = self.connector(proxy=addr, proxy_auth=auth, loop=loop)
self.session = aiohttp.ClientSession(connector=conn, response_class=CustomClientResponse)

0 comments on commit 85ee685

Please sign in to comment.