mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-31 10:01:22 +01:00
Added SOCKS proxy support
This commit is contained in:
@@ -3,8 +3,11 @@ package eu.faircode.email;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
import com.sun.mail.smtp.SMTPTransport;
|
||||
@@ -66,6 +69,24 @@ public class MailService implements AutoCloseable {
|
||||
|
||||
properties = MessageHelper.getSessionProperties();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean socks_enabled = prefs.getBoolean("socks_enabled", false);
|
||||
String socks_proxy = prefs.getString("socks_proxy", "localhost:9050");
|
||||
|
||||
// SOCKS proxy
|
||||
if (socks_enabled) {
|
||||
String[] address = socks_proxy.split(":");
|
||||
String host = (address.length > 0 ? address[0] : null);
|
||||
String port = (address.length > 1 ? address[1] : null);
|
||||
if (TextUtils.isEmpty(host))
|
||||
host = "localhost";
|
||||
if (TextUtils.isEmpty(port))
|
||||
port = "9050";
|
||||
properties.put("mail." + protocol + ".socks.host", host);
|
||||
properties.put("mail." + protocol + ".socks.port", port);
|
||||
Log.i("Using SOCKS proxy=" + host + ":" + port);
|
||||
}
|
||||
|
||||
properties.put("mail.event.scope", "folder");
|
||||
properties.put("mail.event.executor", executor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user