diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 4 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java | 35 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownIPv6FirewallTask.java (renamed from app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownFirewallTask.java) | 4 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/firewall/StartIPv6FirewallTask.java (renamed from app/src/main/java/se/leap/bitmaskclient/firewall/StartFirewallTask.java) | 4 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java | 4 |
5 files changed, 38 insertions, 13 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 7c17bed9..a48d6477 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -194,7 +194,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac VpnStatus.removeStateListener(this); } } - firewallManager.shutdownFirewall(); + firewallManager.stop(); } private boolean runningOnAndroidTV() { @@ -449,7 +449,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac mProcessThread.start(); } - firewallManager.startFirewall(); + firewallManager.start(); new Handler(getMainLooper()).post(() -> { if (mDeviceStateReceiver != null) { diff --git a/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java b/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java index ce402ef8..78166671 100644 --- a/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java @@ -19,6 +19,7 @@ package se.leap.bitmaskclient.firewall; import android.content.Context; import de.blinkt.openvpn.core.VpnStatus; +import se.leap.bitmaskclient.tethering.TetheringObservable; import se.leap.bitmaskclient.tethering.TetheringState; import se.leap.bitmaskclient.utils.PreferenceHelper; @@ -72,14 +73,24 @@ public class FirewallManager implements FirewallCallback { } - public void startFirewall() { - StartFirewallTask task = new StartFirewallTask(this); - task.execute(); + public void start() { + startIPv6Firewall(); + if (TetheringObservable.getInstance().hasAnyTetheringEnabled()) { + TetheringState deviceTethering = TetheringObservable.getInstance().getTetheringState(); + TetheringState vpnTethering = new TetheringState(); + vpnTethering.isWifiTetheringEnabled = deviceTethering.isWifiTetheringEnabled && PreferenceHelper.getWifiTethering(context); + vpnTethering.isUsbTetheringEnabled = deviceTethering.isUsbTetheringEnabled && PreferenceHelper.getUsbTethering(context); + vpnTethering.isBluetoothTetheringEnabled = deviceTethering.isBluetoothTetheringEnabled && PreferenceHelper.getBluetoothTethering(context); + configureTethering(vpnTethering); + } } - - public void shutdownFirewall() { - ShutdownFirewallTask task = new ShutdownFirewallTask(this); - task.execute(); + public void stop() { + shutdownIPv6Firewall(); + TetheringState allowedTethering = new TetheringState(); + allowedTethering.isWifiTetheringEnabled = PreferenceHelper.getWifiTethering(context); + allowedTethering.isUsbTetheringEnabled = PreferenceHelper.getUsbTethering(context); + allowedTethering.isBluetoothTetheringEnabled = PreferenceHelper.getBluetoothTethering(context); + configureTethering(allowedTethering); } public void configureTethering(TetheringState state) { @@ -87,4 +98,14 @@ public class FirewallManager implements FirewallCallback { task.execute(state); } + private void startIPv6Firewall() { + StartIPv6FirewallTask task = new StartIPv6FirewallTask(this); + task.execute(); + } + + private void shutdownIPv6Firewall() { + ShutdownIPv6FirewallTask task = new ShutdownIPv6FirewallTask(this); + task.execute(); + } + } diff --git a/app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownFirewallTask.java b/app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownIPv6FirewallTask.java index 50fa77cd..dbdbf769 100644 --- a/app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownFirewallTask.java +++ b/app/src/main/java/se/leap/bitmaskclient/firewall/ShutdownIPv6FirewallTask.java @@ -8,11 +8,11 @@ import java.lang.ref.WeakReference; import static se.leap.bitmaskclient.firewall.FirewallManager.BITMASK_CHAIN; import static se.leap.bitmaskclient.utils.Cmd.runBlockingCmd; -class ShutdownFirewallTask extends AsyncTask<Void, Boolean, Boolean> { +class ShutdownIPv6FirewallTask extends AsyncTask<Void, Boolean, Boolean> { private WeakReference<FirewallCallback> callbackWeakReference; - ShutdownFirewallTask(FirewallCallback callback) { + ShutdownIPv6FirewallTask(FirewallCallback callback) { callbackWeakReference = new WeakReference<>(callback); } diff --git a/app/src/main/java/se/leap/bitmaskclient/firewall/StartFirewallTask.java b/app/src/main/java/se/leap/bitmaskclient/firewall/StartIPv6FirewallTask.java index 3bf6d684..1dbfb9f8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/firewall/StartFirewallTask.java +++ b/app/src/main/java/se/leap/bitmaskclient/firewall/StartIPv6FirewallTask.java @@ -8,11 +8,11 @@ import java.lang.ref.WeakReference; import static se.leap.bitmaskclient.firewall.FirewallManager.BITMASK_CHAIN; import static se.leap.bitmaskclient.utils.Cmd.runBlockingCmd; -class StartFirewallTask extends AsyncTask<Void, Boolean, Boolean> { +class StartIPv6FirewallTask extends AsyncTask<Void, Boolean, Boolean> { private WeakReference<FirewallCallback> callbackWeakReference; - StartFirewallTask(FirewallCallback callback) { + StartIPv6FirewallTask(FirewallCallback callback) { callbackWeakReference = new WeakReference<>(callback); } diff --git a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java index fc06ee12..79c1ec6d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java +++ b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java @@ -67,4 +67,8 @@ public class TetheringObservable extends Observable { public TetheringState getTetheringState() { return tetheringState; } + + public boolean hasAnyTetheringEnabled() { + return tetheringState.isBluetoothTetheringEnabled || tetheringState.isUsbTetheringEnabled || tetheringState.isWifiTetheringEnabled; + } } |