ipfs-shipyard / py-ipfs-http-client

A python client library for the IPFS API
MIT License
682 stars 201 forks source link

Support for proxy #117

Open nicolas-f opened 6 years ago

nicolas-f commented 6 years ago

Hi,

You are using requests libs. There is an option to use http or socks proxy in this library.

http://docs.python-requests.org/en/master/user/advanced/#proxies

Do you have any tips in order to use ipfsapi with a proxy configuration ?

ex:

import ipfsapi

proxies = {
    'http': 'socks5://@localhost:5555',
    'https': 'socks5://@localhost:5555'
}
api = ipfsapi.connect('myserveur.org', 5002, proxies=proxies)
whereswaldon commented 6 years ago

It isn't currently supported, but it wouldn't be difficult to add it. Right now, extra keyword arguments to the connect method are passed all the way down to here in the defaults parameter: https://github.com/ipfs/py-ipfs-api/blob/master/ipfsapi/http.py#L59 The HTTPClient would need to check whether there were proxies defined, save them as a field (if they were), and use them when it invoked methods from requests. @nicolas-f Would you be interested in adding this?

nicolas-f commented 6 years ago

Sure. I will make a PR.

Thanks

ntninja commented 4 years ago

Working on this. Hardest part turns out to be lack of Multiaddr support for proxies…

ntninja commented 4 years ago

Blocked on https://github.com/multiformats/py-multiaddr/pull/59.