1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-29 15:51:17 +00:00

Add automastic fallback to http on Android 4.x (fixes #137) (fixes #139) (#138)

* Add script to update submodule

* Update publish-release.sh

* Add helper script to build syncthing submodule only

* Enable HTTPS for REST/WebUI only if OS supports it (fixes #137)

* Update ApiRequest to handle both http or https

* Add Constants#osSupportsTLS12

* Update APK version to 0.14.54.2 / 4181

* Update README.md

* Update whatsnew
This commit is contained in:
Catfriend1 2018-12-16 10:44:55 +01:00 committed by GitHub
parent 1371f29c66
commit 7791787bbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 10 deletions

View file

@ -2,7 +2,7 @@
[![License: MPLv2](https://img.shields.io/badge/License-MPLv2-blue.svg)](https://opensource.org/licenses/MPL-2.0)
<a href="https://github.com/Catfriend1/syncthing-android/releases" alt="GitHub release"><img src="https://img.shields.io/github/release/Catfriend1/syncthing-android/all.svg" /></a>
<a href="https://f-droid.org/de/packages/com.github.catfriend1.syncthingandroid" alt="F-Droid release"><img src="https://img.shields.io/badge/f--droid-4180-brightgreen.svg" /></a>
<a href="https://f-droid.org/de/packages/com.github.catfriend1.syncthingandroid" alt="F-Droid release"><img src="https://img.shields.io/f-droid/v/com.github.catfriend1.syncthingandroid.svg" /></a>
# Major enhancements in this fork are:
- Individual sync conditions can be applied per device and per folder (for expert users).

View file

@ -37,8 +37,8 @@ android {
applicationId "com.github.catfriend1.syncthingandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 4180
versionName "0.14.54.1"
versionCode 4181
versionName "0.14.54.2"
testApplicationId 'com.github.catfriend1.syncthingandroid.test'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
playAccountConfig = playAccountConfigs.defaultAccountConfig

View file

@ -157,9 +157,12 @@ public abstract class ApiRequest {
}
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
connection.setHostnameVerifier((hostname, session) -> true);
return connection;
if (mUrl.toString().startsWith("https://")) {
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
connection.setHostnameVerifier((hostname, session) -> true);
return connection;
}
return super.createConnection(url);
}
}

View file

@ -1,6 +1,7 @@
package com.nutomic.syncthingandroid.service;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import java.io.File;
@ -164,4 +165,14 @@ public class Constants {
static File getLogFile(Context context) {
return new File(context.getExternalFilesDir(null), "syncthing.log");
}
/**
* Decide if we should enforce HTTPS when accessing the Web UI and REST API.
* Android 4.4 and earlier don't have support for TLS 1.2 requiring us to
* fall back to an unencrypted HTTP connection to localhost. This applies
* to syncthing core v0.14.53+.
*/
public static final Boolean osSupportsTLS12() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
}
}

View file

@ -119,8 +119,9 @@ public class ConfigXml {
}
public URL getWebGuiUrl() {
String urlProtocol = Constants.osSupportsTLS12() ? "https" : "http";
try {
return new URL("https://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
return new URL(urlProtocol + "://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to parse web interface URL", e);
}
@ -166,9 +167,15 @@ public class ConfigXml {
}
/* Section - GUI */
// Enforce TLS.
Element gui = getGuiElement();
changed = setConfigElement(gui, "tls", "true") || changed;
// Platform-specific: Force REST API and Web UI access to use TLS 1.2 or not.
Boolean forceHttps = Constants.osSupportsTLS12();
if (!gui.hasAttribute("tls") ||
Boolean.parseBoolean(gui.getAttribute("tls")) != forceHttps) {
gui.setAttribute("tls", forceHttps ? "true" : "false");
changed = true;
}
// Set user to "syncthing"
changed = setConfigElement(gui, "user", "syncthing") || changed;

View file

@ -1,5 +1,6 @@
Maintenance
* Updated syncthing core to v0.14.54
* Fallback to http if https tls 1.2 is unavailable on Android 4.x
Enhancements
* Added "Recent changes" UI, click files to open [NEW]
* Specify sync conditions differently for each folder, device [NEW]

7
build_submodule.cmd Normal file
View file

@ -0,0 +1,7 @@
@echo off
cls
cd /d "%~dps0"
REM
gradlew buildNative
REM
pause

12
git_update_submodule.cmd Normal file
View file

@ -0,0 +1,12 @@
@echo off
cls
REM
SET PATH=%PATH%;"%ProgramFiles%\Git\bin"
SET DESIRED_SUBMODULE_VERSION=v0.14.54
REM
cd /d "%~dps0\syncthing\src\github.com\syncthing\syncthing"
REM
git fetch --all
git checkout %DESIRED_SUBMODULE_VERSION%
REM
pause

View file

@ -43,4 +43,4 @@ Release published!
#"
#ACCESS_TOKEN=""
#api_json=$(printf '{"tag_name": "v%s","target_commitish": "master","name": "v%s","body": "%s","draft": false,"prerelease": false}' $version $version $changelog)
#curl --data "$api_json" https://api.github.com/repos/syncthing/syncthing-android/releases?access_token=$ACCESS_TOKEN
#curl --data "$api_json" https://api.github.com/repos/Catfriend1/syncthing-android/releases?access_token=$ACCESS_TOKEN