Debian
如何通過 Linux 命令行獲取 Tor 中繼點?
在使用某些 Tor 瀏覽器時,例如在 iOS 中,我有一個很好的列表,其中包含速度和國家/地區,我可以從中選擇可以使用/從中退出的中繼點。
tor
執行守護程序時,我可以從 Linux 命令行獲取這樣的列表嗎?
正如相關的文章
man tor
所描述的那樣 Tor Browser Bundle 是否記憶體中繼資訊?,系統中有這樣一個帶有記憶體資訊的文件。DataDirectory/cached-consensus 和/或 cached-microdesc-consensus
The most recent consensus network status document we’ve downloaded.
所以在 Debian 中,帶有記憶體 Tor 中繼的文件是
/var/lib/tor/cached-microdesc-consensus
並且其中的資訊可以有效長達 24 小時。(如果不更新,這是正常行為)與這篇文章相關的內容似乎從我的家庭伺服器的第 36 行開始,到第 35963 行結束:
36 r mintberryCrunch ABCTIE984gTgUHkIeZdNvcDTiRE 2016-11-26 20:55:20 88.99.35.166 443 9030 37 m V1CEu0LsXapK9Ci55c+VHLEP89EG+1wWjSjsDSYyC0Y 38 s Fast Guard HSDir Running Stable V2Dir Valid 39 v Tor 0.2.5.12 40 w Bandwidth=16800 41 r CalyxInstitute14 ABG9JIWtRdmE7EFZyI/AZuXjMA4 2016-11-27 01:19:50 162.247.72.201 443 80 42 m hiyRvQn2CqLG7Xgp+eDcQe9u2IpJ44p/qZ+CrgIp+W4 43 s Exit Fast Guard HSDir Running Stable V2Dir Valid 44 v Tor 0.2.8.6 45 w Bandwidth=10800
我在命令行上破解了一個小 bash 腳本,以從該文件中獲取前 20 個加速器繼電器:
sudo egrep ^"r |^w " /var/lib/tor/cached-microdesc-consensus | paste -d " " - - \ | sed "s/Unmeasured=. //" | \ awk ' { printf("%s %s %s ", $2, $6, $10 ); system("geoiplookup " $6 ); } ' | \ cut -f1,2,3,8- -d" " | sed "s/=/ /" | sort -k4 -n -r | head -20
最終結果是:
IPredator 197.231.221.211 Bandwidth 254000 Liberia cry 192.42.115.101 Bandwidth 182000 Netherlands GrmmlLitavisNew 163.172.194.53 Bandwidth 180000 France regar42 62.210.244.146 Bandwidth 164000 France xshells 178.217.187.39 Bandwidth 161000 Poland dopper 192.42.113.102 Bandwidth 159000 Netherlands TorLand1 37.130.227.133 Bandwidth 151000 United Kingdom 0x3d001 91.121.23.100 Bandwidth 151000 France hviv104 192.42.116.16 Bandwidth 149000 Netherlands colosimo 109.236.90.209 Bandwidth 136000 Netherlands Onyx 192.42.115.102 Bandwidth 135000 Netherlands redteam01 209.222.77.220 Bandwidth 134000 United States belalugosidead 217.20.23.204 Bandwidth 129000 United Kingdom redjohn1 62.210.92.11 Bandwidth 124000 France Unnamed 46.105.100.149 Bandwidth 121000 France theblazehenTor 188.138.17.37 Bandwidth 119000 France splitDNA 62.210.82.44 Bandwidth 116000 France radia2 91.121.230.212 Bandwidth 115000 France ArachnideFR5 62.210.206.25 Bandwidth 115000 France quadhead 148.251.190.229 Bandwidth 111000 Germany
或者我家鄉的中繼節點列表:
sudo egrep ^"r |^w " /var/lib/tor/cached-microdesc-consensus | paste -d " " - - \ | sed "s/Unmeasured=. //" | \ awk ' { printf("%s %s %s ", $2, $6, $10 ); system("geoiplookup " $6 ); } ' | \ cut -f1,2,3,8- -d" " | sed "s/=/ /" | grep Portugal | sort -k4 -n -r
輸出:
Laika 51.254.164.50 Bandwidth 47300 Portugal freja 194.88.143.66 Bandwidth 15400 Portugal cserhalmi 188.93.234.203 Bandwidth 1870 Portugal Eleutherius 85.246.243.40 Bandwidth 1400 Portugal luster 94.126.170.165 Bandwidth 1390 Portugal undercity 178.166.97.51 Bandwidth 1180 Portugal helper123 85.245.103.222 Bandwidth 1060 Portugal Pi 94.60.255.42 Bandwidth 271 Portugal TheSpy 85.240.255.230 Bandwidth 142 Portugal MADNET00 89.153.104.243 Bandwidth 78 Portugal MADNET01 82.155.67.190 Bandwidth 14 Portugal
順便說一下,預設情況下,Tor 伺服器/客戶端中的頻寬以 KB 為單位定義。