I would like to run tor service programmatically on Android.
final String path = getNoBackupFilesDir().getCanonicalPath();
final ProcessBuilder torpb = new ProcessBuilder(
String.format("%s/%s", path, "tor"),
"HiddenServiceDir " + path + "/hidden_service",
"HiddenServicePort 80 127.0.0.1:8080"
);
torpb.directory(new File(path));
mProcessTor = torpb.start();
But I will get the following errors message.
Nov 22 23:31:53.041 [notice] Tor 0.4.0.5 running on Linux with Libevent 2.1.8-stable, OpenSSL 1.1.1b, Zlib 1.2.11, Liblzma N/A, and Libzstd N/A.
Nov 22 23:31:53.042 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Nov 22 23:31:53.042 [notice] Configuration file "//.torrc" not present, using reasonable defaults.
Nov 22 23:31:53.058 [notice] Opening Socks listener on 127.0.0.1:9050
Nov 22 23:31:53.058 [notice] Opened Socks listener on 127.0.0.1:9050
Nov 22 23:31:53.058 [warn] Error creating directory //.tor: Read-only file system
Nov 22 23:31:53.058 [warn] Failed to parse/validate config: Couldn't create private data directory "//.tor"
Nov 22 23:31:53.058 [err] Reading config failed--see warnings above.
I think I may miss some parameters to run tor service?
What's //.tor?
Thanks!!
It is working by modify the source code:
final String path = getNoBackupFilesDir().getCanonicalPath();
final ProcessBuilder torpb = new ProcessBuilder(
String.format("%s/%s", path, "tor"),
"DataDirectory",
path + "/tordata",
"HiddenServiceDir",
path + "/hidden_service",
"HiddenServicePort",
"80 127.0.0.1:8080"
);
torpb.directory(new File(path));
mProcessTor = torpb.start();