Browse Source

Added proxy_sockname, proxy_peername, peername properties

main
nibrag 8 years ago
parent
commit
02d76bcbd5
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      aiosocks/protocols.py

+ 25
- 0
aiosocks/protocols.py View File

@@ -37,6 +37,8 @@ class BaseSocksProtocol(asyncio.StreamReaderProtocol):

self._transport = None
self._negotiate_done = False
self._proxy_peername = None
self._proxy_sockname = None

if app_protocol_factory:
self._app_protocol = app_protocol_factory()
@@ -155,6 +157,29 @@ class BaseSocksProtocol(asyncio.StreamReaderProtocol):
def app_transport(self):
return self._transport

@property
def proxy_sockname(self):
"""
Returns the bound IP address and port number at the proxy.
"""
return self._proxy_sockname

@property
def proxy_peername(self):
"""
Returns the IP and port number of the proxy.
"""
sock = self._transport.get_extra_info('socket')
return sock.peername if sock else None

@property
def peername(self):
"""
Returns the IP address and port number of the destination
machine (note: get_proxy_peername returns the proxy)
"""
return self._proxy_peername


class Socks4Protocol(BaseSocksProtocol):
def __init__(self, proxy, proxy_auth, dst, app_protocol_factory, waiter,


Loading…
Cancel
Save