當試圖使用telnet切換Tor IP地址時,我試圖連接到Tor控制端口時運行到SOCKSError::ServerFailure: general SOCKS server failure
通過telnet。但是,如果我產生一個新的進程來進行telnetting,我沒有問題。我不想因爲醜陋而產生新的過程。我希望有人能幫我找到爲什麼我有這個問題和更多的解決方案?Ruby Tor切換IP - 「一般SOCKS服務器故障」,除非我產生一個新的進程telnet到Tor控制端口
要重現:
開始TOR:
tor --SocksPort 9350 --ControlPort 53500 --CookieAuthentication 0 --HashedControlPassword <passwordhash> --DataDirectory /tmp/tor_data/9350
然後運行它使用socksify
設置一個襪服務器這個紅寶石代碼,然後使用tor
寶石Tor::Controller.connect
塊,其連接到Tor的控制端口通過telnet切換到Tor端點:
require 'socksify'
require 'terminator'
require 'tor'
TCPSocket::socks_server = "127.0.0.1"
TCPSocket::socks_port = "9350"
Tor::Controller.connect(:port => 53500) do |tor| #<- error
tor.authenticate("")
tor.signal("newnym")
end
錯誤在Tor::Controller.connect
電話:
SOCKSError::ServerFailure: general SOCKS server failure
如果我更換Tor::Controller.connect
塊與此(產生一個新的進程做遠程登錄),我有成功:
telnet_pid = nil
begin
Terminator.terminate :seconds => 20 do
cmd = "bundle exec ruby -e \"require 'tor'\" -e " +
"\"Tor::Controller.connect(:port => 53500)" +
"{|tor| tor.authenticate(''); tor.signal('newnym')}\""
telnet_pid = Process.spawn(cmd)
Process.wait telnet_pid
end
rescue Terminator.error
puts 'Telnet process to switch Tor endpoint timed out!'
Process.kill('TERM', telnet_pid) if telnet_pid
end