如何使用 postgresql 设置 torsocks

How to set up torsocks with postgresql

当我尝试 运行 我的 Python 程序时

程序 运行 与 torsocks

配合良好

但是当程序需要连接到数据库时(postgresql) 报错不能

如何配置tor使我们的程序能够找到数据库?

我用postgresql

错误照片:

无论我的程序是 Django 还是我使用 sqlalchemy 根本找不到数据库

oem@khoramfar$: proxychains curl https://api.ipify.org/
    [proxychains] config file found: /etc/proxychains.conf
    [proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
    [proxychains] DLL init: proxychains-ng 4.14
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  178.128.235.170:3128 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  51.68.198.158:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  68.183.192.29:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  93.91.86.102:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  41.237.65.105:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  115.124.115.26:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  41.59.254.172:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  1.20.103.196:42792 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  115.85.75.34:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  118.179.223.130:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  139.255.31.146:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  51.222.73.117:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  timeout
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  111.90.179.74:8080 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  96.47.231.58:8020 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607  ...  185.18.214.13:8080  ...  178.128.125.16:34534  ...  106.51.252.227:80 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607  ...  185.18.214.13:8080  ...  178.128.125.16:34534  ...  59.14.228.31:80 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  185.18.214.13:8080 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  178.128.125.16:34534  ...  23.21.48.44:443 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  178.128.125.16:34534  ...  23.21.140.41:443  ...  OK

185.220.100.251

当我使用代理链时,我的 ip 发生了变化,但是当我 运行 程序仍然出现该错误

如果您通过 运行 通过 torsocks 连接到本地数据库,您将无法从程序内部连接到本地数据库,因为这会拦截所有套接字调用以将它们路由到 Tor。像这样通过 Tor 路由所有连接意味着不再有 localhost(无法访问 127.0.0.1)并且数据库连接将通过 Tor。

如果您有一些 HTTP 请求需要在程序中通过 Tor 路由并且您可以更改源,您将需要通过 Tor 通过 SOCKS 代理这些请求,因此只有相关的 HTTP 流量使用 Tor 和其他连接(如数据库)继续照常工作。