问题描述
我们如何在单独的终端窗口中使用 torify 命令获得不同的 Tor 电路?具体来说,如果我在终端 1 窗口中键入命令
torify curl http://icanhazip.com
我收到了我的 IP 地址作为回应。
但如果我同时在另一个终端窗口中尝试,我会得到相同的 IP,这是正常行为。
我想要实现的是在每个新的终端窗口中使用不同的配置文件,以便在不同的终端窗口中获得不同的 IP 地址。
解决方法
使用 -i
(--isolate
) 选项或 --user
和 --pass
获得 stream isolation。
来自man 1 torsocks
:
-u,--user
Set username for the SOCKS5 authentication. Use for circuit isolation in Tor.
Note that you MUST have a password set either by the command line,environment variable or configuration file (torsocks.conf(5).
-p,--pass
Set password for the SOCKS5 authentication. Use for circuit isolation in
Tor. Note that you MUST have a username set either by the command line,environment variable or configuration file (torsocks.conf(5)).
-i,--isolate
Automatic tor isolation. Set the username and password for
the SOCKS5 authentication method to a PID/current time based value
automatically. Username and Password MUST NOT be set.
示例:
torify --user foo --pass password curl https://example.com/
然后,使用一组不同的凭据将为您提供不同的电路并退出中继:
torify --user foo2 --pass password2 curl https://example.com/
您可以通过 curl 直接使用 Tor 的socks 代理实现相同的效果,并指定唯一的代理用户名/密码组合以实现流隔离。
示例:
curl -Lv --socks5-hostname 127.0.0.1:9050 \
--proxy-user foo:password \
https://example.com/
然后,使用一组不同的凭据将为您提供不同的电路并退出中继:
curl -Lv --socks5-hostname 127.0.0.1:9050 \
--proxy-user foo2:password2 \
https://example.com/