Skip to content

add ConnectVPN optional e.blinkt.openvpn.api.serverAddress - #1927

Open
kooritea wants to merge 2 commits into
schwabe:masterfrom
kooritea:master
Open

kooritea wants to merge 2 commits into
schwabe:masterfrom
kooritea:master

Conversation

@kooritea

Copy link
Copy Markdown

Summary

  • Add the optional de.blinkt.openvpn.api.serverAddress extra to the ConnectVPN API.
  • Support tcp://host:port and udp://host:port formats, including bracketed IPv6 addresses.
  • Apply the override to a temporary copy of the selected profile and all enabled connections.
  • Keep the saved VPN profile unchanged.
  • Reject invalid addresses with logging and a user-facing error message.
  • Document the new parameter with adb examples.

Backward Compatibility

Existing ConnectVPN calls continue to work without the new optional extra.

@schwabe

schwabe commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Could you explain the use case for this?

Comment thread README.md
For `ConnectVPN`, the optional `de.blinkt.openvpn.api.serverAddress` extra can temporarily override
all enabled servers in the profile. Use the format `tcp://host:port` or `udp://host:port`.
IPv6 addresses must be enclosed in brackets, for example `tcp://[2001:db8::1]:443`.
The saved profile is not changed.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not use the syntax OpenVPN already has and the app already has a parser for? E.g. the "remote xyz port proto" syntax. That would also more flexible in other ways like allowing a connection block or something like that.

}
}

static VpnProfile createTemporaryProfile(VpnProfile profile, ServerAddress serverAddress) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name is not a great choice here.

}

static void overrideServerAddress(VpnProfile profile, ServerAddress serverAddress) {
profile.mServerName = serverAddress.host;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method needs to be cleaned up. It should just replace the whole list with just one entry instead of modifiying all entries.

Comment thread doc/README.txt Outdated
Use `tcp://host:port` or `udp://host:port` to temporarily override all enabled servers
without changing the saved profile. IPv6 addresses must be enclosed in brackets, for example:

am start-activity -a android.intent.action.MAIN -e de.blinkt.openvpn.api.profileName mediav6-full -e de.blinkt.openvpn.api.serverAddress tcp://203.0.113.5:8443 de.blinkt.openvpn/.api.ConnectVPN

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why mediav6-full?

@kooritea

Copy link
Copy Markdown
Author

I have updated the implementation based on your feedback.

My use case is connecting to an OpenVPN server through a DDNS hostname. Due to slow DNS updates and occasional DNS hijacking by the ISP, the hostname does not always resolve to the correct current IP address. Since I can reliably obtain the server’s current public IP through an external script, I need this API to pass that IP temporarily to ConnectVPN without modifying the saved profile.

Compared with the first revision:

  • The combined tcp://host:port argument was split into the independent serverAddress, serverPort, and protocol extras.
  • For profiles with connections, each extra is optional and the first connection is used as the template.
  • For profiles without connections, all three extras are required to create a temporary connection.
  • The ServerAddress helper was removed, and validation, unbracketed IPv6 support, documentation, and unit tests were added.

The saved profile remains unchanged. The focused tests pass.

This branch has not been deployed

No deployments
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.

2 participants