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

Android Client change server functionality broken after v1.34.0 #6671

Closed
rbangert opened this issue Dec 8, 2022 · 16 comments · Fixed by tailscale/tailscale-android#72
Closed

Comments

@rbangert
Copy link

rbangert commented Dec 8, 2022

What is the issue?

Verified issue with 2 others running headscale servers.

v1.33.97 is the last version that we have found this function to not be broken.

Starting with v1.34.0, we are able to tap the hamburger icon several times to add the change server option, select it, enter the new address, and press restart the app, at which point it closes and never reopens, all of which mirrors the previous version's behavior.

After reopening, the change server option is still available, and the address to the new server is still in the input box, but pressing the button loads the tailscale login, and no connection attempts show on the server.

Steps to reproduce

Upgrade to v1.34.0 or above.

Are there any recent changes that introduced the issue?

No response

OS

Android

OS version

Andriod 13

Tailscale version

1.34.0

Bug report

No response

@rbangert
Copy link
Author

rbangert commented Dec 9, 2022

It appears to have happened in this commit.

https://github.com/tailscale/tailscale-android/blob/7cdd9abc964b1bbecf1f2134387b6416b8c15b6b/cmd/tailscale/main.go#L441-L446

@mihaip
Copy link
Contributor

mihaip commented Dec 9, 2022

@maisem I think this is due to the fast user switching refactoring. When the app is in the initial state (with a new profile) we don't persist any data until there's a login. The os.Exit at https://github.com/tailscale/tailscale-android/blob/7f11150cb6a3df6a1c36125f187b6892024fe46f/cmd/tailscale/main.go is resulting in the ControlURL URL pref being lost.

I think the fix here would be to do something like that what we do for the Mac app with tailscale/corp#8137 where we do the EditPrefs before we call StartLoginInteractive. Or possibly it's closer to what we do in the CLI at

if err := localClient.Start(ctx, ipn.Options{
AuthKey: authKey,
UpdatePrefs: prefs,
, where we can provide the ControlURL as part of the UpdatePrefs when starting.

@rbangert
Copy link
Author

rbangert commented Dec 11, 2022

I was wrong in the comment above, and I think this was actually broken with changes within ipnlocal.

The functionality was introduced with this commit:
tailscale/tailscale-android@d8aedf7?diff=split

Where the little hack involving os.exit(0) had been working until the v1.34.0 release. The custom control URL still persists within the UI after the app restarts, which I believe is because it still is. However it only ends up back in the UI because it's stored in two locations within *stateStore while the app is closed.

When the app opens, it inserts data from *stateStore into ipnlocal in the localBackend structure which enabled the custom control URL to be injected into start() before it gets initialized.

Where I think @maisem rolled through and wrecked this patchy work around by removing ServerURL from localBackend in this commit:
8d84178

Go didn't even exist the last time I wrote a line of code so I'm pretty rusty. But I'll figure out how to make go.mod do what I want later this evening, and build an apk to confirm this.

@blu3r4d0n
Copy link

blu3r4d0n commented Dec 12, 2022

Fwiw, this is also happening on windows. I've documented the process in a video below. This is the latest version of the windows client. I set the registry keys necessary like the headscale docs show. This indicates to me this is likely not an android specific issue

2022-12-12.15-57-05.mp4

@megamorf
Copy link

megamorf commented Dec 17, 2022

I just finished setting up a headscale instance for the first time and was confused why I wasn't able to sign in with the Android app. This explains it. How fast do you think you can ship a bugfix? Unfortunately I'm not a good coder but I can help with testing the fix.

@DentonGentry
Copy link
Contributor

We have not released 1.34.1 for Android yet, working on a fix. Unfortunately we may need a change in https://github.com/tailscale/tailscale to do so which means it would need a 1.34.2 release.

DentonGentry added a commit to tailscale/tailscale-android that referenced this issue Dec 17, 2022
Updates tailscale/tailscale#6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
@DentonGentry
Copy link
Contributor

DentonGentry commented Dec 17, 2022

Current effort is in tailscale/tailscale-android@main...serverurl :

  • doesn't exit the App, instead calls b.backend.Start() to make it generate the loginURL again.
  • removes the "...and restart" text from the UI

It still isn't working though. I can see Start() being called, and it looks like it stops the backend and never restarts it:

12-17 15:32:42.703 22250 22277 I com.tailscale.ipn: 15.5M/119.6M SetPrefs: Prefs{ra=true dns=true want=false url="https://login.example.com" host="Pixel 3a XL" Persist=nil}
12-17 15:32:42.704 22250 22277 I com.tailscale.ipn: 15.5M/119.6M Start
12-17 15:32:42.704 22250 22272 I com.tailscale.ipn: 15.5M/119.6M control: client.Shutdown()
12-17 15:32:42.705 22250 22272 I com.tailscale.ipn: 15.5M/119.6M control: client.Shutdown: inSendStatus=0
12-17 15:32:42.706 22250 22290 I com.tailscale.ipn: 15.6M/119.6M control: mapRoutine: quit
12-17 15:32:42.707 22250 22281 I com.tailscale.ipn: 15.6M/119.6M control: Client.Shutdown done.
12-17 15:32:42.707 22250 22277 I com.tailscale.ipn: 15.6M/119.6M Backend: logs: be:0123456789abcdef0123456789abcdef fe:
... hangs forever...

Clicking on "Sign in with other" just sits there, never launching a browser window.

WantRunning is false but I'd still expect the backend to start up and sit in the NeedsLogin state.
Setting WantRunning=true in the struct passed to SetPrefs makes no difference.

I also tried using EditPrefs in case there is some side-effect, but no difference.


We do see:
12-17 15:32:42.707 22250 22277 I com.tailscale.ipn: 15.6M/119.6M Backend: logs: be:0123456789abcdef0123456789abcdef fe:

which is near the end of Start():

b.logf("Backend: logs: be:%v fe:%v", blid, opts.FrontendLogID)

DentonGentry added a commit to tailscale/tailscale-android that referenced this issue Dec 18, 2022
Updates tailscale/tailscale#6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
@DentonGentry
Copy link
Contributor

Figured out the deadlock and got past that point, testing some more.

DentonGentry added a commit to tailscale/tailscale-android that referenced this issue Dec 18, 2022
With the Fast User Switching support in Tailscale 1.34,
it is no longer necessary (nor sufficient) to exit
and restart the app, as the settings are saved upon
first connection.

Therefore:
- do not restart the app after changing the control URL,
  just go back to the authentication screen.
- call `ipn/ipnlocal/local.go:Start()` to reinitialize
  the backend using the new auth URL.

Fixes tailscale/tailscale#6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
@blu3r4d0n
Copy link

Appreciate the work on this @DentonGentry

DentonGentry added a commit to tailscale/tailscale-android that referenced this issue Dec 18, 2022
With the Fast User Switching support in Tailscale 1.34,
it is no longer necessary (nor sufficient) to exit
and restart the app, as the settings are saved upon
first connection.

Therefore:
- do not restart the app after changing the control URL,
  just go back to the authentication screen.
- call `ipn/ipnlocal/local.go:Start()` to reinitialize
  the backend using the new auth URL.

Fixes tailscale/tailscale#6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
@DentonGentry
Copy link
Contributor

I believe this is fixed in 1.34.1, which is in review for the Play Store release.

DentonGentry added a commit to tailscale/tailscale-android that referenced this issue Dec 18, 2022
With the Fast User Switching support in Tailscale 1.34,
it is no longer necessary (nor sufficient) to exit
and restart the app, as the settings are saved upon
first connection.

Therefore:
- do not restart the app after changing the control URL,
  just go back to the authentication screen.
- call `ipn/ipnlocal/local.go:Start()` to reinitialize
  the backend using the new auth URL.

Fixes tailscale/tailscale#6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
(cherry picked from commit 0244fd1)
@blu3r4d0n
Copy link

@DentonGentry I can confirm that it is fixed. I just built it with the latest commits and it worked as expected. 🥇

@geekscrapy
Copy link

I just downloaded the latest Android version but can't activate the Change Server option. It doesn't appear after many attempts

Screenshot_20230507_161324
Screenshot_20230507_161414_Google Play Store

@DentonGentry
Copy link
Contributor

Not that menu. Click log out, then click the menu on the authentication screen. On the fourth click, the Change Server URL item will appear.

Screenshot_20230507-051608

@axxonadmin
Copy link

axxonadmin commented Oct 8, 2023

Android tailscale client 1.48.2

Although I was able to enable "custom server", and it worked with my headscale, but
every time I'm trying to log in after restart or logout with "sign in with other"
it gets me to "login.tailscale.com" (instead of my server) untill I go in "change sarver" and press "save" button again.

@cracknel
Copy link

cracknel commented Oct 22, 2023

I can confirm what @axxonadmin is saying.
L.E.:
Found an open issue reporting exactly this: #9788

@travisdj
Copy link

travisdj commented May 8, 2024

This is still an issue. I've even reinstalled my headscale server to make sure it wasn't an issue there. Very frustrating since at one point I could have tasker connect me to my headscale server when I left the house since I'm behind cgnat. Hope to see a fix.

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

Successfully merging a pull request may close this issue.

9 participants