Skip to content

Commit

Permalink
Disable SOCKS proxy support per feature flag
Browse files Browse the repository at this point in the history
We don't want people to use this incomplete implementation believing the proxy
will be used for all their connections. This could have serious privacy
implications, e.g. when using Tor via SOCKS proxy.

See also #980
  • Loading branch information
cketti committed Mar 15, 2016
1 parent 2e79811 commit e6b3993
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions k9mail/build.gradle
Expand Up @@ -68,13 +68,17 @@ android {
}

buildConfigField "boolean", "DEVELOPER_MODE", "false"

buildConfigField "boolean", "FEATURE_SOCKS_PROXY", "false"
}

debug {
applicationIdSuffix ".debug"
testCoverageEnabled rootProject.testCoverage

buildConfigField "boolean", "DEVELOPER_MODE", "true"

buildConfigField "boolean", "FEATURE_SOCKS_PROXY", "true"
}
}

Expand Down
4 changes: 2 additions & 2 deletions k9mail/src/main/java/com/fsck/k9/Account.java
Expand Up @@ -19,7 +19,6 @@
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;

import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
Expand Down Expand Up @@ -1282,7 +1281,8 @@ public Store getRemoteStore() throws MessagingException {
}

public ProxySettings getProxySettings() {
return new ProxySettings(K9.isSocksProxyEnabled(), K9.getSocksProxyHost(), K9.getSocksProxyPort());
boolean enabled = Features.isSocksProxySupportEnabled() && K9.isSocksProxyEnabled();
return new ProxySettings(enabled, K9.getSocksProxyHost(), K9.getSocksProxyPort());
}

// It'd be great if this actually went into the store implementation
Expand Down
8 changes: 8 additions & 0 deletions k9mail/src/main/java/com/fsck/k9/Features.java
@@ -0,0 +1,8 @@
package com.fsck.k9;


public class Features {
public static boolean isSocksProxySupportEnabled() {
return BuildConfig.FEATURE_SOCKS_PROXY;
}
}
31 changes: 22 additions & 9 deletions k9mail/src/main/java/com/fsck/k9/activity/setup/Prefs.java
Expand Up @@ -20,6 +20,7 @@
import android.text.TextUtils;
import android.widget.Toast;

import com.fsck.k9.Features;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationHideSubject;
import com.fsck.k9.K9.NotificationQuickDelete;
Expand Down Expand Up @@ -430,14 +431,24 @@ public void onCancel() {
initListPreference(mSplitViewMode, K9.getSplitViewMode().name(),
mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues());

mUseSocksProxy = (CheckBoxPreference) findPreference(PREFERENCE_SOCKS_PROXY);
mUseSocksProxy.setChecked(K9.isSocksProxyEnabled());
CheckBoxPreference useSocksProxy = (CheckBoxPreference) findPreference(PREFERENCE_SOCKS_PROXY);
EditTextPreference socksProxyHost = (EditTextPreference) findPreference(PREFERENCE_SOCKS_PROXY_HOST);
EditTextPreference socksProxyPort = (EditTextPreference) findPreference(PREFERENCE_SOCKS_PROXY_PORT);

mSocksProxyHost = (EditTextPreference) findPreference(PREFERENCE_SOCKS_PROXY_HOST);
mSocksProxyHost.setText(K9.getSocksProxyHost());
if (Features.isSocksProxySupportEnabled()) {
mUseSocksProxy = useSocksProxy;
mSocksProxyHost = socksProxyHost;
mSocksProxyPort = socksProxyPort;

mSocksProxyPort = (EditTextPreference) findPreference(PREFERENCE_SOCKS_PROXY_PORT);
mSocksProxyPort.setText(Integer.toString(K9.getSocksProxyPort()));
useSocksProxy.setChecked(K9.isSocksProxyEnabled());
socksProxyHost.setText(K9.getSocksProxyHost());
socksProxyPort.setText(Integer.toString(K9.getSocksProxyPort()));
} else {
PreferenceScreen networkPreferences = (PreferenceScreen) findPreference("network_preferences");
networkPreferences.removePreference(useSocksProxy);
networkPreferences.removePreference(socksProxyHost);
networkPreferences.removePreference(socksProxyPort);
}
}

private static String themeIdToName(K9.Theme theme) {
Expand Down Expand Up @@ -538,9 +549,11 @@ private void saveSettings() {
K9.setHideUserAgent(mHideUserAgent.isChecked());
K9.setHideTimeZone(mHideTimeZone.isChecked());

K9.setUseSocksProxy(mUseSocksProxy.isChecked());
K9.setSocksProxyHost(mSocksProxyHost.getText());
K9.setSocksProxyPort(Integer.parseInt(mSocksProxyPort.getText()));
if (Features.isSocksProxySupportEnabled()) {
K9.setUseSocksProxy(mUseSocksProxy.isChecked());
K9.setSocksProxyHost(mSocksProxyHost.getText());
K9.setSocksProxyPort(Integer.parseInt(mSocksProxyPort.getText()));
}

StorageEditor editor = storage.edit();
K9.save(editor);
Expand Down

0 comments on commit e6b3993

Please sign in to comment.