Forum: Ruby Socket connection to the Tor server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Camille R. (Guest)
on 2009-01-24 01:42
Hi,

I'd like to code a script able to connect to the Tor server. Find above
the command line script. I'd like to do the same in ruby. I tried using
TCPSocket, Net::Telnet... no way.

Thank you
Camille


SHELL SESSION:
camille$ telnet 127.0.0.1 9051
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
authenticate
250 OK

...

quit
250 closing connection
Connection closed by foreign host.
Camille R. (Guest)
on 2009-01-24 16:35
I found finally how to do that. I forgot to write \r\n at each end of
line.
Here the code:

require 'net/telnet'

t = TCPSocket.new("localhost",'9051')
t.puts("authenticate\r\n")
puts t.gets
#...
t.puts("quit\r\n")
puts t.gets


Camille R. wrote:
> Hi,
>
> I'd like to code a script able to connect to the Tor server. Find above
> the command line script. I'd like to do the same in ruby. I tried using
> TCPSocket, Net::Telnet... no way.
>
> Thank you
> Camille
>
>
> SHELL SESSION:
> camille$ telnet 127.0.0.1 9051
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> authenticate
> 250 OK
>
> ...
>
> quit
> 250 closing connection
> Connection closed by foreign host.
This topic is locked and can not be replied to.