mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
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:
parent
656697128e
commit
462a013ae2
5 changed files with 52 additions and 7 deletions
|
@ -35,8 +35,8 @@ android {
|
||||||
applicationId "com.nutomic.syncthingandroid"
|
applicationId "com.nutomic.syncthingandroid"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 4155
|
versionCode 4158
|
||||||
versionName "0.10.17"
|
versionName "0.10.18-beta2"
|
||||||
testApplicationId 'com.nutomic.syncthingandroid.test'
|
testApplicationId 'com.nutomic.syncthingandroid.test'
|
||||||
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
|
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
|
||||||
playAccountConfig = playAccountConfigs.defaultAccountConfig
|
playAccountConfig = playAccountConfigs.defaultAccountConfig
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.net.Uri;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.android.volley.AuthFailureError;
|
import com.android.volley.AuthFailureError;
|
||||||
import com.android.volley.DefaultRetryPolicy;
|
import com.android.volley.DefaultRetryPolicy;
|
||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
|
@ -17,10 +18,22 @@ import com.android.volley.toolbox.StringRequest;
|
||||||
import com.android.volley.toolbox.Volley;
|
import com.android.volley.toolbox.Volley;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
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.net.URL;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.Map;
|
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 {
|
public abstract class ApiRequest {
|
||||||
|
|
||||||
private static final String TAG = "ApiRequest";
|
private static final String TAG = "ApiRequest";
|
||||||
|
@ -47,7 +60,7 @@ public abstract class ApiRequest {
|
||||||
private RequestQueue getVolleyQueue() {
|
private RequestQueue getVolleyQueue() {
|
||||||
if (sVolleyQueue == null) {
|
if (sVolleyQueue == null) {
|
||||||
Context context = mContext.getApplicationContext();
|
Context context = mContext.getApplicationContext();
|
||||||
sVolleyQueue = Volley.newRequestQueue(context, new HurlStack());
|
sVolleyQueue = Volley.newRequestQueue(context, new NetworkStack());
|
||||||
}
|
}
|
||||||
return sVolleyQueue;
|
return sVolleyQueue;
|
||||||
}
|
}
|
||||||
|
@ -132,4 +145,34 @@ public abstract class ApiRequest {
|
||||||
|
|
||||||
getVolleyQueue().add(imageRequest);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class ConfigXml {
|
||||||
|
|
||||||
public URL getWebGuiUrl() {
|
public URL getWebGuiUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL("http://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
|
return new URL("https://" + getGuiElement().getElementsByTagName("address").item(0).getTextContent());
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new RuntimeException("Failed to parse web interface URL", e);
|
throw new RuntimeException("Failed to parse web interface URL", e);
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,9 @@ public class ConfigXml {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Section - GUI */
|
/* Section - GUI */
|
||||||
// Disable TLS.
|
// Enforce TLS.
|
||||||
Element gui = getGuiElement();
|
Element gui = getGuiElement();
|
||||||
changed = setConfigElement(gui, "tls", "false") || changed;
|
changed = setConfigElement(gui, "tls", "true") || changed;
|
||||||
|
|
||||||
// Set user to "syncthing"
|
// Set user to "syncthing"
|
||||||
changed = setConfigElement(gui, "user", "syncthing") || changed;
|
changed = setConfigElement(gui, "user", "syncthing") || changed;
|
||||||
|
|
|
@ -110,9 +110,11 @@ for target in BUILD_TARGETS:
|
||||||
environ = os.environ.copy()
|
environ = os.environ.copy()
|
||||||
environ.update({
|
environ.update({
|
||||||
'GOPATH': module_dir,
|
'GOPATH': module_dir,
|
||||||
|
'GO111MODULE': 'on',
|
||||||
'CGO_ENABLED': '1',
|
'CGO_ENABLED': '1',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
subprocess.check_call(['go', 'mod', 'download'], cwd=syncthing_dir)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'go', 'run', 'build.go', '-goos', 'android', '-goarch', target['goarch'], '-cc', os.path.join(standalone_ndk_dir, 'bin', target['cc'])
|
'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)
|
] + pkg_argument + ['-no-upgrade', 'build'], env=environ, cwd=syncthing_dir)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1e69997ecdbf87ceaad76bd0149d98f560f4fdb5
|
Subproject commit 4299af1c639e43f73fa601dfb8b5f3f857a13718
|
Loading…
Reference in a new issue