原始文献 / 论坛帖 / Re: TOR and I2P

Re: TOR and I2P

Bitcointalk · 2010-02-04 00:30:50 UTC

AuthorSatoshi Nakamoto
TitleRe: TOR and I2P
Date2010-02-04 00:30:50 UTC
ForumBitcointalk · 原文

用代理端口 9050 时,它只会尝试连一次 IRC,然后放弃,因为它知道大概率永远连不上——IRC 服务器封禁了所有 TOR 出口节点。如果你用别的端口,它会以为那是个普通的老式代理,以越来越长的间隔不断重试 IRC。你不该用 Polipo 或 Privoxy,那些是 http 过滤器和缓存,改动了比特币的消息就会把它搞坏。比特币可能会试图重连来对抗。你应该用 9050 端口。

正如 riX 说的,"is giving Tor only an IP address. Apps that do DNS..." 这些警告不用担心。代理模式下比特币根本不用 DNS。

因为比特币通过 Tor 连不上 IRC,它不知道现在哪些节点在线,所以只能把最近见过的节点都试一遍。它尽量省着用连接尝试,但大家又希望启动时连得快、断线后重连快。它用的算法是:一个 IP 上次成功连接是越久以前的事,重试间隔就越长。比如,一个 24 小时前见过的节点,它会每 5 小时试连一次。一旦有了至少 2 个连接,超过一周没见过的就不再试;有了 5 个连接,超过 24 小时没见过的就不再试。

英文原文

When using proxy port 9050, it will only make one attempt to connect to IRC, then give up, since it knows it will probably always fail because IRC servers ban all the TOR exit nodes.  If you're using another port, it would assume it might be a regular old normal proxy and would keep retrying IRC at longer and longer intervals.  You should not use Polipo or Privoxy as those are http filters and caches that would corrupt Bitcoin's messages if they make any changes.  Bitcoin might be trying to overcome it by reconnecting.  You should use port 9050.

As riX says, the "is giving Tor only an IP address. Apps that do DNS..." warnings are nothing to worry about.  Bitcoin doesn't use DNS at all in proxy mode.

Since Bitcoin can't get through to IRC through Tor, it doesn't know which nodes are currently online, so it has to try all the recently seen nodes.  It tries to conserve connection attempts as much as possible, but also people want it to connect quickly when they start it up and reconnect quickly if disconnected.  It uses an algorithm where it tries an IP less and less frequently the longer ago it was successful connected.  For example, for a node it saw 24 hours ago, it would wait 5 hours between connection attempts.  Once it has at least 2 connections, it won't try anything over a week old, and 5 connections it won't try anything over 24 hours old.