Fast forward master to current release branch (#1282)

* Bump version number

* Restore modules

* Bump version

* Revert "Disable HTTPS (fixes #1255)"

This reverts commit 1f82ec0fc6.

* Bump version
This commit is contained in:
Simon Frei 2019-02-26 20:49:57 +01:00 committed by Audrius Butkevicius
parent 656697128e
commit 462a013ae2
5 changed files with 52 additions and 7 deletions

View File

@ -35,8 +35,8 @@ android {
applicationId "com.nutomic.syncthingandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 4155
versionName "0.10.17"
versionCode 4158
versionName "0.10.18-beta2"
testApplicationId 'com.nutomic.syncthingandroid.test'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
playAccountConfig = playAccountConfigs.defaultAccountConfig

View File

@ -7,6 +7,7 @@ import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
@ -17,10 +18,22 @@ import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.nutomic.syncthingandroid.service.Constants;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
public abstract class ApiRequest {
private static final String TAG = "ApiRequest";
@ -47,7 +60,7 @@ public abstract class ApiRequest {
private RequestQueue getVolleyQueue() {
if (sVolleyQueue == null) {
Context context = mContext.getApplicationContext();
sVolleyQueue = Volley.newRequestQueue(context, new HurlStack());
sVolleyQueue = Volley.newRequestQueue(context, new NetworkStack());
}
return sVolleyQueue;
}
@ -132,4 +145,34 @@ public abstract class ApiRequest {
getVolleyQueue().add(imageRequest);
}
/**
* Extends {@link HurlStack}, uses {@link #getSslSocketFactory()} and disables hostname
* verification.
*/
private class NetworkStack extends HurlStack {
public NetworkStack() {
super(null, getSslSocketFactory());
}
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
connection.setHostnameVerifier((hostname, session) -> true);
return connection;
}
}
private SSLSocketFactory getSslSocketFactory() {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
File httpsCertPath = Constants.getHttpsCertFile(mContext);
sslContext.init(null, new TrustManager[]{new SyncthingTrustManager(httpsCertPath)},
new SecureRandom());
return sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException | KeyManagementException e) {
Log.w(TAG, e);
return null;
}
}
}

View File

@ -107,7 +107,7 @@ public class ConfigXml {
public URL getWebGuiUrl() {
try {
return new URL("http://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
return new URL("https://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to parse web interface URL", e);
}
@ -154,9 +154,9 @@ public class ConfigXml {
}
/* Section - GUI */
// Disable TLS.
// Enforce TLS.
Element gui = getGuiElement();
changed = setConfigElement(gui, "tls", "false") || changed;
changed = setConfigElement(gui, "tls", "true") || changed;
// Set user to "syncthing"
changed = setConfigElement(gui, "user", "syncthing") || changed;

View File

@ -110,9 +110,11 @@ for target in BUILD_TARGETS:
environ = os.environ.copy()
environ.update({
'GOPATH': module_dir,
'GO111MODULE': 'on',
'CGO_ENABLED': '1',
})
subprocess.check_call(['go', 'mod', 'download'], cwd=syncthing_dir)
subprocess.check_call([
'go', 'run', 'build.go', '-goos', 'android', '-goarch', target['goarch'], '-cc', os.path.join(standalone_ndk_dir, 'bin', target['cc'])
] + pkg_argument + ['-no-upgrade', 'build'], env=environ, cwd=syncthing_dir)

@ -1 +1 @@
Subproject commit 1e69997ecdbf87ceaad76bd0149d98f560f4fdb5
Subproject commit 4299af1c639e43f73fa601dfb8b5f3f857a13718