Skip to content

Add localdevvpn://restart - #39

Open
Elvis-Luo wants to merge 1 commit into
jkcoxson:mainfrom
Elvis-Luo:restart-url
Open

Elvis-Luo wants to merge 1 commit into
jkcoxson:mainfrom
Elvis-Luo:restart-url

Conversation

@Elvis-Luo

Copy link
Copy Markdown

Problem

A tunnel can look connected while its packet tunnel extension is gone, for example after iOS ends the extension under memory pressure. The utun interface stays up but carries nothing, and localdevvpn://enable does nothing because the tunnel already counts as started. A JIT tool that relies on the tunnel has no way to recover it without the user.

Change

New localdevvpn://restart:

  • Manager first. It loads the tunnel manager before anything else (as the Shortcuts action does), so it also works when the URL cold-launches the app.
  • Restart. The new TunnelManager.restartVPN() stops the tunnel and starts it again once it reports disconnected, through the existing ShouldStartLocalDevVPNAfterDisconnect path. A tunnel that isn't running is just started.
  • Callback. With ?scheme=NAME, it opens NAME:// once the tunnel has gone down and come back up, or after 10 s at most.

Testing

  • An unsigned Release build passes against current main (iOS 15 deployment target, no overrides).
  • Not run on a device. An earlier, simpler version (stop, fixed-delay start, fixed-delay callback) is in my own build of LocalDevVPN on an iPad Pro (M4) and an iPhone Duo, where a modified StikDebug calls it when its tunnel stays down. I haven't seen that path fire on a device.

A tunnel can look connected while its packet tunnel extension is gone (iOS
ends it under memory pressure): the utun interface stays up but carries
nothing, and localdevvpn://enable does nothing because the tunnel already
counts as started.

localdevvpn://restart loads the tunnel manager first (as the Shortcuts
action does, so it also works when the URL cold-launches the app), then
TunnelManager.restartVPN() stops the tunnel and starts it again once it
reports disconnected, through the existing
ShouldStartLocalDevVPNAfterDisconnect path. A tunnel that is not running is
just started.

With ?scheme=NAME it opens NAME:// once the tunnel has gone down and come
back up, or after 10 s at most.

Compiled, not run on a device.
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

Successfully merging this pull request may close these issues.

1 participant