Closed mstniy closed 2 years ago
The manifest contains a content provider, org.torproject.android.ui.hiddenservices.storage
, but there doesn't seem to be any mention of it in the code.
Perhaps it is yet to be implemented?
This feature wasn't necessarily intended to be an automated app API. The idea is that you run some kind of local server app, which is listening on localhost. Then, you as a user setup the app service within Orbot, which then gives you back the onion address in the UI for you to share, copy and paste, etc, as needed.
That said, there is an Intent UI for an app to request an onion service.
You can see an example of it here: https://github.com/guardianproject/haven/blob/master/src/main/java/org/havenapp/main/SettingsFragment.java#L720 https://github.com/guardianproject/haven/blob/master/src/main/java/org/havenapp/main/SettingsFragment.java#L341
My understanding is the following: Orbot has two types of Onion services: user services are created by the user, and work the way you mentioned. App services are created by other applications via intents, like https://github.com/guardianproject/haven/blob/master/src/main/java/org/havenapp/main/SettingsFragment.java#L725. The activity response used by https://github.com/guardianproject/haven/blob/master/src/main/java/org/havenapp/main/SettingsFragment.java#L341 seems to have disappeared after commit guardianproject/orbot@0b1e7be203f30c5f3d99abfb018f34b99873d80a, which removed support for V2 services. The new intent that enables V3 services doesn't seem to return a similar response, thus the impossibility for the requester to obtain the domain name assigned to the service.
Ah that is a regression. I missed that it was removed in the v2 removal work. @bitmold let's talk about that!
@n8fr8 @mstniy Ok, so I have this fixed in this commit though it is a bit rough around the edges: https://github.com/guardianproject/orbot/commit/e39bde36aad3f8af910274c379a71d6b7a71fb53
The old implementation for v2 services I wasn't a fan of. When an app like haven requested a v2 service, Orbot would start up a new thread and every 3 seconds would check to see if the hostname for that service was generated, if it found one, it would send it back to the calling app.
This approach adds a new action to Orbot Service ACTION_UPDATE_ONION_NAMES
. When OrbotService receives this it does the same logic it does in startTor()
. This is why previously in Orbot you would have to restart the app to get an onion service URL, since the update logic only occured in startTor()
. Now, this logic still occurs in startTor()
but the service will also invoke it whenever it receives an Intent
with this action.
Whenever OrbotService updates its onion names, it now sends a STATUS_V3_NAMES_UPDATED
status back to OrbotMainActivity
. This means that rather than looping indefinitely, Orbot responds when the info is ready.
One open question I have at the moment is at when point in tor's lifecycle does it generate the onion domain. Does an actual tor connection need to be fully established? And if not, Orbot should send the info back to the requesting app as soon as possible, without waiting for the tor connection.
The original implementation of this API for V2 Onion Addresses was pretty limited. For instance, with the old API you would request a V2 Onion Service by giving Orbot an onion port and a local port, however if a service already existed on that local port, the requesting application would get whatever onion domain exists there (whether it was created by the user within Orbot for an unrelated purpose, or by another application).
Some ideas going forward:
While this discussion unfolds, I intend to work on the following things in the meantime:
Orbot does support app services, which is when an app requests Orbot to expose a given local port as an Onion service. However, that seems to be where it ends. Orbot does not provide a mechanism for applications to monitor or manipulate their Onion services, including querying the Onion domains they are assigned, making this feature useless.
Please correct me if I am mistaken.