Rclone + TOR, SOCKS?

Hi all, I use the Linux Tails distribution, which is primarily set up TOR to access the Internet

any application that wants to access the Internet must be set to:
SOCKS Server: 127.0.0.1
Port: 9150
SOCKS Version: 5

Could you please advise me how to set Rclone to work with TOR?

You can use a SOCKS proxy with rclone - check out the docs here: https://rclone.org/faq/#can-i-use-rclone-with-an-http-proxy

I don't know whether that will make it work with TOR or not - let's hope so!

@ncw @sweh (sweh, I apologize, but I see that you are very experienced in this issue)

I don't know how to use these commands correctly.

export http_proxy=http://proxyserver:12345
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy

I tried:

rclone export http_proxy=http://proxyserver:12345
rclone config export http_proxy=http://proxyserver:12345

I tried to put it directly in the configuration file but it didn't work for me:


I tried both variants: "127.0.0.1/9150" "127.0.0.1:9150"

What is the correct syntax for using Proxy SOCKS5 ?

EDIT:
I searched the forum again and if I am not wrong, the syntax should look like this:

But it still doesn't connect through the TOR network what am I doing wrong?

The export commands are Unix commands, not rclone commands, and they create Unix environment variables.

So you'll need to do something like

export http_proxy=http://proxyserver:12345
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
rclone copy foo bar:baz

Now this refers to a HTTP proxy, not a SOCKS proxy. I've not tested with socks, myself, but this might work...

export http_proxy=socks5://127.0.0.1:9150
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
rclone copy myfile jana:myfile

Thanks! (I understand it now)
So we can say that Rclone has no support for SOCKS5 proxy, right?

My English isn't the best, but I'd edit the FAQ > "So, on Linux, you may end up with code similar to"
I would write clearly that these are UNIX commands :laughing:

You can set those environment variables on Windows too. Eg in CMD you type

set  http_proxy=whatever

I think it should work if you get the environment variables right.

the best thing would be to support the SOCKS type proxy and not only HTTP in this way all the protocols (sftp etc) could be used in corporate environments.

b.b.

The socks proxy should work for nearly all the backends but not sftp or FTP. That would require support from the the upstream modules. It might be supported I haven't checked.

bbassotti, I think you might be getting confused with names.

The FAQ explains, but basically http_proxy means "when you want to talk to a http server, use this proxy setting". Simillary https_proxy means "when you want to talk to a https server, use this proxy setting". Now the value determines the proxy protol, so socks5://127.0.0.1:9150 should(! I've not tested) say "use the SOCKS5 proxy on port 9150".

Hence these settings:

export http_proxy=socks5://127.0.0.1:9150
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
rclone copy myfile jana:myfile

that is true for HTTP/S protocol, it a matter of lines of codes:

package main

import (
"fmt"
"io/ioutil"
"net/http"
"os"

"golang.org/x/net/proxy"

)

const (
PROXY_ADDR = "127.0.0.1:9050"
URL = "http://skunksworkedp2cg.onion/sites.html"
)

func main() {
// create a socks5 dialer
dialer, err := proxy.SOCKS5("tcp", PROXY_ADDR, nil, proxy.Direct)
if err != nil {
fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
os.Exit(1)
}
// setup a http client
httpTransport := &http.Transport{}
httpClient := &http.Client{Transport: httpTransport}
// set our socks5 as the dialer
httpTransport.Dial = dialer.Dial
// create a request
req, err := http.NewRequest("GET", URL, nil)
if err != nil {
fmt.Fprintln(os.Stderr, "can't create request:", err)
os.Exit(2)
}
// use the http client to fetch the page
resp, err := httpClient.Do(req)
if err != nil {
fmt.Fprintln(os.Stderr, "can't GET page:", err)
os.Exit(3)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Fprintln(os.Stderr, "error reading body:", err)
os.Exit(4)
}
fmt.Println(string(b))
}

Are you saying rclone needs some work to support socks? If so would you like to send a pull request?

bb

1 Like

you cannot unless you recompile rclone so that it becomes an executable that uses dynamic system libraries. by default rlcone is an independent executable ie it does not require external libraries. all the various socks client (dante, tsocks, etc) use the preload technique in order to catch the connect and divert it to the socks libraries. NCW please don't let us recompile rclone natively supports socks :slight_smile:

These will only work with C programs - rclone is a Go program and doesn't use the shared C library so the preload technique won't work :frowning:

rclone has some SOCKS support but the support may not be 100% - if you would like to help make it better that would be great!