@@ -160,7 +160,8 @@ fun SyncActivity.setupServerListUi(binding: DialogServerUrlBinding, dialog: Mate
160160 val protocol = if (
161161 actualUrl == BuildConfig .PLANET_XELA_URL ||
162162 actualUrl == BuildConfig .PLANET_SANPABLO_URL ||
163- actualUrl == BuildConfig .PLANET_URIUR_URL
163+ actualUrl == BuildConfig .PLANET_URIUR_URL ||
164+ isLocalNetwork(actualUrl)
164165 ) " http://" else " https://"
165166 editor.putString(" serverProtocol" , protocol).apply ()
166167 if (serverCheck) {
@@ -210,7 +211,6 @@ fun SyncActivity.setupServerListUi(binding: DialogServerUrlBinding, dialog: Mate
210211 }
211212 serverUrl.isEnabled = false
212213 serverPassword.isEnabled = false
213- editor.putString(" serverProtocol" , getString(R .string.https_protocol)).apply ()
214214}
215215
216216fun SyncActivity.onNeutralButtonClick (dialog : MaterialDialog ) {
@@ -330,3 +330,13 @@ fun SyncActivity.setupManualConfigEnabled(binding: DialogServerUrlBinding, dialo
330330 setUrlAndPin(settings.getBoolean(" switchCloudUrl" , false ))
331331 protocolSemantics()
332332}
333+
334+ private fun isLocalNetwork (url : String ): Boolean {
335+ val host = url.split(" :" ).firstOrNull()?.split(" /" )?.firstOrNull() ? : url
336+ return host.startsWith(" 192.168." ) ||
337+ host.startsWith(" 10." ) ||
338+ host.matches(Regex (" ^172\\ .(1[6-9]|2[0-9]|3[0-1])\\ ..*" )) ||
339+ host == " localhost" ||
340+ host == " 127.0.0.1" ||
341+ host.endsWith(" .local" )
342+ }
0 commit comments