Skip to content

Make connection test URL editable#3253

Open
TurboTheTurtle wants to merge 2 commits into
shadowsocks:masterfrom
TurboTheTurtle:editable-connection-test-url
Open

Make connection test URL editable#3253
TurboTheTurtle wants to merge 2 commits into
shadowsocks:masterfrom
TurboTheTurtle:editable-connection-test-url

Conversation

@TurboTheTurtle

Copy link
Copy Markdown

Summary:

  • Add a public setting for the connection test URL.
  • Preserve https://cp.cloudflare.com as the initialized default.
  • Use the configured URL when running the HTTPS connectivity test.
  • Add the setting to both mobile and TV settings.

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:

  • git diff --check
  • JAVA_HOME=/opt/homebrew/opt/openjdk@21 ANDROID_HOME=/Users/andy/Library/Android/sdk ./gradlew :mobile:compileDebugKotlin 📺compileGoogleDebugKotlin
  • JAVA_HOME=/opt/homebrew/opt/openjdk@21 ANDROID_HOME=/Users/andy/Library/Android/sdk ./gradlew :mobile:installDebug
  • Emulator smoke: launched the debug app, opened Settings > Advanced, and verified Connection test URL shows https://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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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
}
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.

Make connection test URL editable

2 participants