【发布时间】:2017-08-03 04:24:04
【问题描述】:
尝试使用 telnet 切换 Tor IP 地址时,我在尝试通过 telnet 连接到 Tor 控制端口时遇到SOCKSError::ServerFailure: general SOCKS server failure。但是,如果我生成一个新进程来进行远程登录,我没有问题。我不想产生一个新进程,因为它很丑。我希望有人可以帮助我找到为什么我会遇到这个问题以及更可靠的解决方案?
复制:
启动tor:
tor --SocksPort 9350 --ControlPort 53500 --CookieAuthentication 0 --HashedControlPassword <passwordhash> --DataDirectory /tmp/tor_data/9350
然后运行这个使用socksify设置socks服务器的ruby代码,然后使用tor gem Tor::Controller.connect块通过telnet连接到Tor控制端口来切换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
【问题讨论】: