torproject / stem

Python controller library for Tor
https://stem.torproject.org/
GNU Lesser General Public License v3.0
257 stars 75 forks source link

Add support for hostname instead of ip address in `Controller.from_port` #116

Open Dekwin opened 2 years ago

Dekwin commented 2 years ago

Add support for hostname(like "tor-container", or "localhost") as address parameter in Controller.from_port Currently address parameter only supports ipv4 address.

It is useful when Tor is running in one Docker container, but the Stem connection establishing from another container.

example:

from stem.control import Controller

address="127.0.0.1"
# address="localhost" add support for this, currently this throws an exception
with Controller.from_port(address=address, port=9051) as controller:
   ...
atagar commented 2 years ago

Oddly GitHub didn't provide a useful link for the PR. Here it is: https://github.com/torproject/stem/pull/122