运行 带有 ProcessBuilder 的 tor 二进制文件

Running tor binary with ProcessBuilder

我想 运行 在 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();

但我会收到以下错误消息。

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.

我想我可能会遗漏 运行 服务的一些参数?
//.tor 是什么?

谢谢!!

修改源码即可:

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();