Make connection test URL editable#3253
Open
TurboTheTurtle wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a user-configurable setting for the connectivity test endpoint so networks that can’t reach the Cloudflare URL can still run the app’s HTTPS connection test.
Changes:
- Introduces a new public preference key (
connectionTestUrl) and surfaces it in both mobile and TV settings UI. - Initializes the setting with the prior hardcoded default (
https://cp.cloudflare.com). - Updates the HTTPS connectivity test to use the configured URL.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tv/src/main/res/xml/pref_main.xml | Adds an editable “Connection test URL” preference to TV settings. |
| tv/src/main/java/com/github/shadowsocks/tv/MainPreferenceFragment.kt | Binds URL-appropriate input behavior to the new TV preference. |
| mobile/src/main/res/xml/pref_global.xml | Adds an editable “Connection test URL” preference to mobile global settings. |
| mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt | Binds URL-appropriate input behavior to the new mobile preference. |
| core/src/main/res/values/strings.xml | Adds the display string for the new setting title. |
| core/src/main/java/com/github/shadowsocks/utils/Constants.kt | Adds a new preference key constant for the connection test URL. |
| core/src/main/java/com/github/shadowsocks/preference/EditTextPreferenceModifiers.kt | Adds a URL input modifier for EditTextPreference. |
| core/src/main/java/com/github/shadowsocks/preference/DataStore.kt | Adds storage/default initialization and a getter for the new setting. |
| core/src/main/java/com/github/shadowsocks/net/HttpsTest.kt | Uses the configured URL when creating the connectivity test connection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var portTransproxy: Int | ||
| get() = getLocalPort(Key.portTransproxy, 8200) | ||
| set(value) = publicStore.putString(Key.portTransproxy, value.toString()) | ||
| val connectionTestUrl get() = publicStore.getString(Key.connectionTestUrl) ?: DEFAULT_CONNECTION_TEST_URL |
Comment on lines
+83
to
+89
| val conn = try { | ||
| URL(DataStore.connectionTestUrl).openConnection(DataStore.proxy) as? HttpURLConnection | ||
| ?: throw IOException("URL is not HTTP(S)") | ||
| } catch (e: IOException) { | ||
| status.value = Status.Error.IOFailure(e) | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
https://cp.cloudflare.comas the initialized default.Why:
Some networks cannot reach the default connectivity endpoint. Letting users choose the URL makes the connection test useful in those environments without changing proxy behavior.
Closes #3225.
Validation:
Connection test URLshowshttps://cp.cloudflare.com.Please preserve author attribution if this PR is squashed or reworked:
Co-authored-by: Andy Ye 35905412+TurboTheTurtle@users.noreply.github.com