[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-talk] torified nodejs: server crashes



On 10 Feb (23:58:53), Konstantin Rybakov wrote:
> Dear developers,
> 
> I am trying to develop a simple networking application based on node.js
> 'net'  library. Server supposed to run in torified environment.
> 
> My setup is linux Ubuntu 16.04.

On 16.04, "torsocks" package is 2.1.0 which old so first thing you might want
to do is try the latest that is torsocks 2.2.0. Building it from source is
probably what you'll need to do (see the README.md in the tarball):

https://people.torproject.org/~dgoulet/torsocks/torsocks-2.2.0.tar.xz
Sig: https://people.torproject.org/~dgoulet/torsocks/torsocks-2.2.0.tar.xz.asc

> 
> intalled tor and torsocks. Torsocks allows inbound connection and outbound
> on localhost.
> 
> nodejs app is basically a minimal tcp server based on 'net' library. I run
> it like this: torsocks nodejs app.js, while tor process is also runnning
> 
> The server starts, but when client connects - it crashes with seg fault.
> 
> When I run the same node.js server in regular shell without torsocks, but
> when tor is running - it works fine
> 
> So far I tried plain C and python servers - they both worked in torified
> shell, but node.js failing.
> 
> 
> Is there a way to make nodejs working under torsocks? What could be the
> problem?

Difficult to say. What I would do is open a ticket on trac.torproject.org
under the "Core Tor/Torsocks" component if possible. If not, you can always
email here some more details about the segfault.

If you could do a couple of things and put those on the ticket or here.

1) Try this:

$ TORSOCKS_LOG_LEVEL=5 TORSOCKS_LOG_FILE_PATH=/tmp/torsocks.log torsocks nodejs [...]

2) I have no idea what are the implication of using gdb with nodejs but you
can try to use it and see where the segfaults happen:

    $ gdb nodejs
    set follow-fork-mode child
    set environment LD_PRELOAD /path/to/libtorsocks.so
      ["libtorsocks.so" is usually in "/usr/lib/torsocks/libtorsocks.so" or if
        you built it from source, will be in
        "/usr/local/lib/torsocks/libtorsocks.so"]
    run

Then once you hit the segfault, use "bt full" to get a stack trace and put it
on the ticket.

3) Finally, you could also use strace to see if it is within a syscall that
torsocks hijacks that exploded:

$ strace -f -o /tmp/strace-torsocks.log torsocks nodejs [...]

Hope this help! Just a quick note, making the full nodejs work with torsocks
could end up being quite complicated. You should also consider a way to use
nodejs SOCKS proxy option (if any) instead and make your application use Tor
socks port.

Cheers!
David

-- 
1xYrq8XhE25CKCQqvcX/cqKg04v1HthMMM3PwaRqqdU=

Attachment: signature.asc
Description: PGP signature

-- 
tor-talk mailing list - tor-talk@xxxxxxxxxxxxxxxxxxxx
To unsubscribe or change other settings go to
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk