carsonyl / pypac

Find and use proxy auto-config (PAC) files with Python and Requests.
https://pypac.readthedocs.io
Apache License 2.0
71 stars 18 forks source link

multiple source ip addresss test #53

Closed kaushik853 closed 4 years ago

kaushik853 commented 4 years ago

Hi, Can you tell how can i test it with multiple source ip address . Something i tried like

from requests_toolbelt.adapters import source
session = PACSession(pac)
list_source_ip_and_url = [("10.129.xx.yy", "https://google.com"), ("10.189.yy.xx", "https://random.com/Surveyor.Web/")]
responses = []
try:
    for source_ip, url in list_source_ip_and_url:
        new_source = source.SourceAddressAdapter(source_ip)
        session.mount('http://', new_source)
        session.mount('https://', new_source)
        responses.append(session.get(url))
    print(responses)
except Exception as e:
    print(e)

I am getting error like: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x033D5547>: Failed to establish a new connection: [WinError 10049] The requested address is not valid in its context')) Looks like im hitting some requests module error.

carsonyl commented 4 years ago

I suspect this issue is not within PyPAC or PACSession, so I can't help you there. You should investigate your usage of SourceAddressAdapter.