Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control port file not created #128

Open
torwarrior opened this issue Jul 8, 2019 · 13 comments
Open

Control port file not created #128

torwarrior opened this issue Jul 8, 2019 · 13 comments

Comments

@torwarrior
Copy link

torwarrior commented Jul 8, 2019

I/OnionProxyManager: Starting Tor
I/OnionProxyManager: Starting process
I/OnionProxyManager: Waiting for control port
W/OnionProxyManager: Control port file not created
I/FileUtilities: /data/user/0/ch.blinkenlights.android.vanilla/files/tor_exec/lib/tor/control.txt

I use tor for android project. Control port has been creating each time just as empty file. Any thoughts how can I fix it or find the reason?

I`ve also tried on the android instrumentation test in the repository, and result is still the same.
Снимок экрана 2019-07-08 в 14 30 59

@sisbell
Copy link
Contributor

sisbell commented Jul 8, 2019

Sometimes the Tor process will output errors to its normal inputStream.

To get more info, try going OnionProxyManager.spawnTorProcess and changing the following line

eatStream(torProcess.getErrorStream());

to
eatStream(torProcess.getInputStream());

I opened issue #129 to track adding the inputstream to console for debugging.

@torwarrior
Copy link
Author

Thanks a lot for quick reply. While I am trying to research the solution, I will put logs here...

E/OnionProxyManager: Jul 08 23:04:53.471 [notice] Tor 0.3.5.8 (git-5030edfb534245ed) running on Linux with Libevent 2.1.7-beta, OpenSSL 1.0.2p, Zlib 1.2.11, Liblzma 5.2.3, and Libzstd 1.3.2.
E/OnionProxyManager: Jul 08 23:04:53.471 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
E/OnionProxyManager: Jul 08 23:04:53.472 [notice] Read configuration file "/data/user/0/ch.blinkenlights.android.vanilla/files/tor_exec/torrc".
E/OnionProxyManager: Jul 08 23:04:53.482 [notice] Opening Control listener on 127.0.0.1:0
E/OnionProxyManager: Jul 08 23:04:53.483 [notice] Control listener listening on port 45210.
E/OnionProxyManager: Jul 08 23:04:53.483 [notice] Opened Control listener on 127.0.0.1:0
E/OnionProxyManager: Jul 08 23:04:53.483 [notice] DisableNetwork is set. Tor will not make or accept non-control network connections. Shutting down all existing connections.

@torwarrior
Copy link
Author

torwarrior commented Jul 8, 2019

Seems that the issue is related to the torrc file, I will share the initialization code

val installDir = File(context.filesDir, "tor_exec")
val torConfig = AndroidTorConfig.createConfig(installDir, installDir, context)

val onionProxyManager = AndroidOnionProxyManager(
    context,
    torConfig,
    SisTorInstaller(context, installDir),
    null,
    null,
    null
)

onionProxyManager.setup()
onionProxyManager.startWithRepeat(4 * 60, 5, true)
public class SisTorInstaller extends AndroidTorInstaller {

    public SisTorInstaller(Context context, File configDir) {
        super(context, configDir);
    }

    @Override
    public InputStream openBridgesStream() throws IOException {
        return context.getResources().openRawResource(R.raw.bridges);
    }
}

And here is 'torrc' file from the folder which I pass as the 'installDir' param during the initialization- folder name 'tor_exec':

RunAsDaemon 1
AvoidDiskWrites 0
ControlPort auto
SOCKSPort 0
DNSPort 0
TransPort 0
CookieAuthentication 1
DisableNetwork 1

@torwarrior
Copy link
Author

torwarrior commented Jul 11, 2019

@sisbell can you orient me, please, with place where I should check the behavior? Maybe you have some ideas, as I see you have a lot of experience with tor

@sisbell
Copy link
Contributor

sisbell commented Jul 12, 2019

@torwarrior There are two common causes of startup failure. First would be if the torrc file is specifying some port that another app (or instance of tor) is also using. You can check if other tor processes are running on your system which may be using the ports.

The second possibility is if the torrc file is not configured properly or has some invalid value. You can test this by taking the torrc file and running it directly with tor from the command line:

tor -f torrc

If that is bad, it will throw up some errors in the console

@SilverGhostBS
Copy link

Hello, sorry to ressurect an old thread, but I am having the same issue, basically it seems the torrc file is the one that comes straight from the tor-binary package, and it seems to be missing the directive "ControlPortWriteToFile" so the control.txt file is initialized as an empty file by the TorInstaller, but never actually written by TOR.

@eighthave
Copy link

eighthave commented Mar 25, 2020 via email

@ProofOfKeags
Copy link

OK So I'm having the same issue at this point. I haven't been able to successfully get the tor bin to start up. Ive tried in many different configurations. It also happens even when I try to run the smoke test in this repo. Any ideas?

@maxgmer
Copy link

maxgmer commented Apr 22, 2020

i have a same problem

Hello, sorry to ressurect an old thread, but I am having the same issue, basically it seems the torrc file is the one that comes straight from the tor-binary package, and it seems to be missing the directive "ControlPortWriteToFile" so the control.txt file is initialized as an empty file by the TorInstaller, but never actually written by TOR.

same issue for me

@05nelsonm
Copy link

05nelsonm commented Jun 12, 2020

Bumping into the same thing.... Even adding "ControlPortWriteToFile" to my default torrc file as @SilverGhostBS suggested doesn't seem to do the trick.

keep getting an IllegalArgumentException at startup for the FileObserver

E/FileObserver: Unhandled exception in FileObserver io.matthewnelson.topl_android.util.WriteObserver@15e726
    java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter s
        at io.matthewnelson.topl_android.util.WriteObserver.onEvent(Unknown Source:2)
        at android.os.FileObserver$ObserverThread.onEvent(FileObserver.java:123)
        at android.os.FileObserver$ObserverThread.observe(Native Method)
        at android.os.FileObserver$ObserverThread.run(FileObserver.java:86)

@05nelsonm
Copy link

05nelsonm commented Jun 13, 2020

Been playing around with Tor Browser's tor-android-service project (I assume most of you here are as well).

Finding that you've gotta call updateTorConfig().asString() from TorSettingsBuilder then write it to your torrc file before calling start such that all the settings you've entered via your TorSettings class are appropriately reflected.

TorConfig will have the file pathway for your cookieAuthFile that is needed for your torrc file's ControlPortWriteToFile

Also, in the tor-android-service project the torrc file asset shouldn't even be needed when you use the TorSettingsBuilder's updateTorConfig method.

@05nelsonm
Copy link

05nelsonm commented Jun 19, 2020

Also finding that the WriteObserver is throwing an IllegalArgumentException because it's being sent a null File due to it being deleted, then recreated and the reference for torConfig.cookieAuthFile is not being reset. Same with the controlPortFile.

@eighthave
Copy link

eighthave commented Jun 30, 2020

These kinds of issues is why I put a bunch of work into eliminating the ControlPort file and the hunt for the connection. The TorService I implemented uses a UNIX domain socket: https://gitlab.com/eighthave/tor-android/-/blob/927a2a25/tor-android-binary/src/main/java/org/torproject/jni/TorService.java#L299

Ultimately, I think TorService should communicate with Tor using stdin/stdout or even direct function call. Here's more on that:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants