Browse Source

Added option for local ssl configuration

pull/438/head
Mario Franco 7 years ago
parent
commit
058bb14843
  1. 5
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  2. 12
      app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java
  3. 3
      app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java
  4. 1
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  5. 5
      app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java
  6. 5
      app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettings.java
  7. 5
      app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java
  8. 5
      app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java
  9. 5
      app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java
  10. 2
      app/src/main/res/values/strings.xml
  11. 5
      app/src/main/res/xml/pref_server.xml

5
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -146,6 +146,7 @@ public class ApplicationSettings {
// @formatter:off // @formatter:off
Daemon type = Daemon.fromCode(prefs.getString("server_type_" + order, null)); Daemon type = Daemon.fromCode(prefs.getString("server_type_" + order, null));
boolean ssl = prefs.getBoolean("server_sslenabled_" + order, false); boolean ssl = prefs.getBoolean("server_sslenabled_" + order, false);
boolean localSsl = prefs.getBoolean("server_localsslenabled_" + order, false);
String port = prefs.getString("server_port_" + order, null); String port = prefs.getString("server_port_" + order, null);
if (TextUtils.isEmpty(port)) if (TextUtils.isEmpty(port))
@ -172,7 +173,7 @@ public class ApplicationSettings {
parseInt(localPort, parseInt(port, Daemon.getDefaultPortNumber(type, ssl))), parseInt(localPort, parseInt(port, Daemon.getDefaultPortNumber(type, ssl))),
prefs.getString("server_localnetwork_" + order, null), prefs.getString("server_localnetwork_" + order, null),
parseInt(port, Daemon.getDefaultPortNumber(type, ssl)), parseInt(port, Daemon.getDefaultPortNumber(type, ssl)),
ssl, ssl, localSsl,
prefs.getBoolean("server_ssltrustall_" + order, false), prefs.getBoolean("server_ssltrustall_" + order, false),
prefs.getString("server_ssltrustkey_" + order, null), prefs.getString("server_ssltrustkey_" + order, null),
prefs.getString("server_folder_" + order, null), prefs.getString("server_folder_" + order, null),
@ -213,6 +214,7 @@ public class ApplicationSettings {
edit.putString("server_localnetwork_" + i, prefs.getString("server_localnetwork_" + (i + 1), null)); edit.putString("server_localnetwork_" + i, prefs.getString("server_localnetwork_" + (i + 1), null));
edit.putString("server_port_" + i, prefs.getString("server_port_" + (i + 1), null)); edit.putString("server_port_" + i, prefs.getString("server_port_" + (i + 1), null));
edit.putBoolean("server_sslenabled_" + i, prefs.getBoolean("server_sslenabled_" + (i + 1), false)); edit.putBoolean("server_sslenabled_" + i, prefs.getBoolean("server_sslenabled_" + (i + 1), false));
edit.putBoolean("server_localsslenabled_" + i, prefs.getBoolean("server_localsslenabled_" + (i + 1), false));
edit.putBoolean("server_ssltrustall_" + i, prefs.getBoolean("server_ssltrustall_" + (i + 1), false)); edit.putBoolean("server_ssltrustall_" + i, prefs.getBoolean("server_ssltrustall_" + (i + 1), false));
edit.putString("server_ssltrustkey_" + i, prefs.getString("server_ssltrustkey_" + (i + 1), null)); edit.putString("server_ssltrustkey_" + i, prefs.getString("server_ssltrustkey_" + (i + 1), null));
edit.putString("server_folder_" + i, prefs.getString("server_folder_" + (i + 1), null)); edit.putString("server_folder_" + i, prefs.getString("server_folder_" + (i + 1), null));
@ -237,6 +239,7 @@ public class ApplicationSettings {
edit.remove("server_localnetwork_" + max); edit.remove("server_localnetwork_" + max);
edit.remove("server_port_" + max); edit.remove("server_port_" + max);
edit.remove("server_sslenabled_" + max); edit.remove("server_sslenabled_" + max);
edit.remove("server_localsslenabled_" + max);
edit.remove("server_ssltrustall_" + max); edit.remove("server_ssltrustall_" + max);
edit.remove("server_ssltrustkey_" + max); edit.remove("server_ssltrustkey_" + max);
edit.remove("server_folder_" + max); edit.remove("server_folder_" + max);

12
app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java

@ -56,6 +56,7 @@ public class ServerSetting implements SimpleListItem {
private final boolean alarmOnFinishedDownload; private final boolean alarmOnFinishedDownload;
private final boolean alarmOnNewTorrent; private final boolean alarmOnNewTorrent;
private final boolean ssl; private final boolean ssl;
private final boolean localSsl;
private final boolean sslTrustAll; private final boolean sslTrustAll;
private final String sslTrustKey; private final String sslTrustKey;
private final String excludeFilter; private final String excludeFilter;
@ -83,7 +84,7 @@ public class ServerSetting implements SimpleListItem {
* @param isAutoGenerated Whether this setting was generated rather than manually inputed by the user * @param isAutoGenerated Whether this setting was generated rather than manually inputed by the user
*/ */
public ServerSetting(int key, String name, Daemon type, String address, String localAddress, int localPort, String localNetwork, int port, public ServerSetting(int key, String name, Daemon type, String address, String localAddress, int localPort, String localNetwork, int port,
boolean ssl, boolean sslTrustAll, String sslTrustKey, String folder, boolean useAuthentication, String username, boolean ssl, boolean localSsl, boolean sslTrustAll, String sslTrustKey, String folder, boolean useAuthentication, String username,
String password, String extraPass, OS os, String downloadDir, String ftpUrl, String ftpPassword, int timeout, String password, String extraPass, OS os, String downloadDir, String ftpUrl, String ftpPassword, int timeout,
boolean alarmOnFinishedDownload, boolean alarmOnNewTorrent, String excludeFilter, String includeFilter, boolean alarmOnFinishedDownload, boolean alarmOnNewTorrent, String excludeFilter, String includeFilter,
boolean isAutoGenerated) { boolean isAutoGenerated) {
@ -96,6 +97,7 @@ public class ServerSetting implements SimpleListItem {
this.localNetwork = localNetwork; this.localNetwork = localNetwork;
this.port = port; this.port = port;
this.ssl = ssl; this.ssl = ssl;
this.localSsl = localSsl;
this.sslTrustAll = sslTrustAll; this.sslTrustAll = sslTrustAll;
this.sslTrustKey = sslTrustKey; this.sslTrustKey = sslTrustKey;
this.folder = folder; this.folder = folder;
@ -155,6 +157,10 @@ public class ServerSetting implements SimpleListItem {
return ssl; return ssl;
} }
public boolean getLocalSsl() {
return localSsl;
}
public boolean getSslTrustAll() { public boolean getSslTrustAll() {
return sslTrustAll; return sslTrustAll;
} }
@ -305,6 +311,7 @@ public class ServerSetting implements SimpleListItem {
} }
String addressToUse = address; String addressToUse = address;
int portToUse = port; int portToUse = port;
boolean sslEnable = ssl;
if (!TextUtils.isEmpty(localNetwork) && !TextUtils.isEmpty(localAddress) && if (!TextUtils.isEmpty(localNetwork) && !TextUtils.isEmpty(localAddress) &&
!TextUtils.isEmpty(connectedToNetwork)) { !TextUtils.isEmpty(connectedToNetwork)) {
String[] localNetworks = localNetwork.split("\\|"); String[] localNetworks = localNetwork.split("\\|");
@ -312,11 +319,12 @@ public class ServerSetting implements SimpleListItem {
if (connectedToNetwork.equals(network)) { if (connectedToNetwork.equals(network)) {
addressToUse = localAddress; addressToUse = localAddress;
portToUse = localPort; portToUse = localPort;
sslEnable = localSsl;
break; break;
} }
} }
} }
return new DaemonSettings(name, type, addressToUse, portToUse, ssl, sslTrustAll, sslTrustKey, folder, return new DaemonSettings(name, type, addressToUse, portToUse, sslEnable, sslTrustAll, sslTrustKey, folder,
useAuthentication, username, password, extraPass, os, downloadDir, ftpUrl, ftpPassword, timeout, useAuthentication, username, password, extraPass, os, downloadDir, ftpUrl, ftpPassword, timeout,
alarmOnFinishedDownload, alarmOnNewTorrent, Integer.toString(key), isAutoGenerated); alarmOnFinishedDownload, alarmOnNewTorrent, Integer.toString(key), isAutoGenerated);
} }

3
app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java

@ -107,6 +107,8 @@ public class SettingsPersistence {
editor.putString("server_port_" + postfix, server.getString("port")); editor.putString("server_port_" + postfix, server.getString("port"));
if (server.has("ssl")) if (server.has("ssl"))
editor.putBoolean("server_sslenabled_" + postfix, server.getBoolean("ssl")); editor.putBoolean("server_sslenabled_" + postfix, server.getBoolean("ssl"));
if (server.has("local_ssl"))
editor.putBoolean("server_localsslenabled_" + postfix, server.getBoolean("local_ssl"));
if (server.has("ssl_accept_all")) if (server.has("ssl_accept_all"))
editor.putBoolean("server_ssltrustall_" + postfix, server.getBoolean("ssl_accept_all")); editor.putBoolean("server_ssltrustall_" + postfix, server.getBoolean("ssl_accept_all"));
if (server.has("ssl_trust_key")) if (server.has("ssl_trust_key"))
@ -271,6 +273,7 @@ public class SettingsPersistence {
server.put("local_port", prefs.getString("server_localport_" + postfixi, null)); server.put("local_port", prefs.getString("server_localport_" + postfixi, null));
server.put("port", prefs.getString("server_port_" + postfixi, null)); server.put("port", prefs.getString("server_port_" + postfixi, null));
server.put("ssl", prefs.getBoolean("server_sslenabled_" + postfixi, false)); server.put("ssl", prefs.getBoolean("server_sslenabled_" + postfixi, false));
server.put("local_ssl", prefs.getBoolean("server_localsslenabled_" + postfixi, false));
server.put("ssl_accept_all", prefs.getBoolean("server_ssltrustall_" + postfixi, false)); server.put("ssl_accept_all", prefs.getBoolean("server_ssltrustall_" + postfixi, false));
server.put("ssl_trust_key", prefs.getString("server_ssltrustkey_" + postfixi, null)); server.put("ssl_trust_key", prefs.getString("server_ssltrustkey_" + postfixi, null));
server.put("folder", prefs.getString("server_folder_" + postfixi, null)); server.put("folder", prefs.getString("server_folder_" + postfixi, null));

1
app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -78,6 +78,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("server_ftppass"); initTextPreference("server_ftppass");
initBooleanPreference("server_disableauth"); initBooleanPreference("server_disableauth");
initBooleanPreference("server_sslenabled"); initBooleanPreference("server_sslenabled");
initBooleanPreference("server_localsslenabled");
initBooleanPreference("server_ssltrustall", false, "server_sslenabled"); initBooleanPreference("server_ssltrustall", false, "server_sslenabled");
initTextPreference("server_ssltrustkey", null, "server_sslenabled"); initTextPreference("server_ssltrustkey", null, "server_sslenabled");
onPreferencesChanged(); onPreferencesChanged();

5
app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java

@ -55,8 +55,9 @@ public class DediseedboxSettings extends SeedboxSettingsImpl implements SeedboxS
null, null,
443, 443,
null, null,
443, 443,
true, true,
true,
false, false,
null, null,
"/rutorrent/plugins/httprpc/action.php", "/rutorrent/plugins/httprpc/action.php",

5
app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettings.java

@ -55,8 +55,9 @@ public class SeedstuffSettings extends SeedboxSettingsImpl implements SeedboxSet
null, null,
443, 443,
null, null,
443, 443,
true, true,
true,
false, false,
null, null,
"/user/" + user, "/user/" + user,

5
app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java

@ -53,8 +53,9 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe
null, null,
0, 0,
null, null,
type == Daemon.uTorrent? 5010: 443, type == Daemon.uTorrent? 5010: 443,
type == Daemon.uTorrent? false: true, type == Daemon.uTorrent? false: true,
type == Daemon.uTorrent? false: true,
false, false,
null, null,
type == Daemon.Deluge? "/deluge": null, type == Daemon.Deluge? "/deluge": null,

5
app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java

@ -52,8 +52,9 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe
null, null,
0, 0,
null, null,
443, 443,
true, true,
true,
false, false,
null, null,
"/RPC2", "/RPC2",

5
app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java

@ -53,8 +53,9 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox
null, null,
0, 0,
null, null,
443, 443,
true, true,
true,
false, false,
null, null,
rpc, rpc,

2
app/src/main/res/values/strings.xml

@ -293,6 +293,8 @@
<string name="pref_disableauth_info">Don\'t send username and password</string> <string name="pref_disableauth_info">Don\'t send username and password</string>
<string name="pref_sslenable">Use SSL</string> <string name="pref_sslenable">Use SSL</string>
<string name="pref_sslenable_info">Connect using https</string> <string name="pref_sslenable_info">Connect using https</string>
<string name="pref_local_sslenable">Use SSL on local network</string>
<string name="pref_local_sslenable_info">Connect using https</string>
<string name="pref_sslkey">Custom SSL thumbprint (SHA-1)</string> <string name="pref_sslkey">Custom SSL thumbprint (SHA-1)</string>
<string name="pref_sslkey_info">Permit only connections to this specific certificate</string> <string name="pref_sslkey_info">Permit only connections to this specific certificate</string>
<string name="pref_sslacceptall">Accept all SSL certificates</string> <string name="pref_sslacceptall">Accept all SSL certificates</string>

5
app/src/main/res/xml/pref_server.xml

@ -84,6 +84,11 @@
android:title="@string/pref_sslenable" android:title="@string/pref_sslenable"
android:summary="@string/pref_sslenable_info" android:summary="@string/pref_sslenable_info"
android:defaultValue="false" /> android:defaultValue="false" />
<CheckBoxPreference
android:key="server_localsslenabled"
android:title="@string/pref_local_sslenable"
android:summary="@string/pref_local_sslenable_info"
android:defaultValue="false" />
<CheckBoxPreference <CheckBoxPreference
android:key="server_ssltrustall" android:key="server_ssltrustall"
android:title="@string/pref_sslacceptall" android:title="@string/pref_sslacceptall"

Loading…
Cancel
Save