Results 1 to 2 of 2

Thread: How do I connect a QTcpSocket to a TOR .onion site?

  1. #1
    Join Date
    Apr 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How do I connect a QTcpSocket to a TOR .onion site?

    I would like to test that an .onion site ran by TOR is actually up, using Qt. So what I do is:

    Qt Code:
    1. proxy.setType(QNetworkProxy::DefaultProxy);
    2. proxy.setHostName("127.0.0.1");
    3. proxy.setPort(9050);
    4. proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability | proxy.capabilities()) ;
    5.  
    6. QTcpSocket socket ;
    7. socket.setProxy(proxy) ;
    8.  
    9. socket.connectToHost("ulno4bbebwsr23n6.onion",9023);
    10.  
    11. if(!socket.waitForConnected(5000))
    12. std::cerr << "Error: " << socket.errorString().toStdString() << std::endl;
    To copy to clipboard, switch view to plain text mode 

    But what I get is an error message in the console that says "Error: Host not found". Apparently the proxy is not able to resolve the .onion address.

    I tried Socks5Proxy, but that causes "Error: Operation on socket is not supported". So I suppose I should stick to the DefaultProxy type.

    I'm 100% sure the onion site is alive and running. So what's wrong in my code??

    Thanks in advance for any help!

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default [Solved] Re: How do I connect a QTcpSocket to a TOR .onion site?

    I'm answering to myself, since I found it: the url should be "http://[...].onion", not just simply "[...].onion". Then it works.

Similar Threads

  1. I am new in this site
    By Leydislan in forum Newbie
    Replies: 0
    Last Post: 7th April 2010, 05:58
  2. about this site
    By incapacitant in forum General Discussion
    Replies: 7
    Last Post: 2nd February 2006, 20:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.