summaryrefslogtreecommitdiff
path: root/ipscrambling/src
diff options
context:
space:
mode:
Diffstat (limited to 'ipscrambling/src')
-rw-r--r--ipscrambling/src/main/AndroidManifest.xml2
-rw-r--r--ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/IpScramblerModule.kt (renamed from ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IpScramblerModule.kt)41
-rw-r--r--ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt8
-rw-r--r--ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IIpScramblerModule.kt54
4 files changed, 33 insertions, 72 deletions
diff --git a/ipscrambling/src/main/AndroidManifest.xml b/ipscrambling/src/main/AndroidManifest.xml
index e948147..d6496f0 100644
--- a/ipscrambling/src/main/AndroidManifest.xml
+++ b/ipscrambling/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foundation.e.privacymodules.tor"
+ package="foundation.e.advancedprivacy.ipscrambler"
android:installLocation="internalOnly"
>
diff --git a/ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IpScramblerModule.kt b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/IpScramblerModule.kt
index 1c39330..d1f01a0 100644
--- a/ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IpScramblerModule.kt
+++ b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/IpScramblerModule.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package foundation.e.privacymodules.ipscrambler
+package foundation.e.advancedprivacy.ipscrambler
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
@@ -29,8 +29,6 @@ import android.os.Looper
import android.os.Message
import android.util.Log
import androidx.localbroadcastmanager.content.LocalBroadcastManager
-import foundation.e.privacymodules.ipscrambler.IIpScramblerModule.Listener
-import foundation.e.privacymodules.ipscrambler.IIpScramblerModule.Status
import org.torproject.android.service.OrbotConstants
import org.torproject.android.service.OrbotConstants.ACTION_STOP_FOREGROUND_TASK
import org.torproject.android.service.OrbotService
@@ -38,7 +36,16 @@ import org.torproject.android.service.util.Prefs
import java.security.InvalidParameterException
@SuppressLint("CommitPrefEdits")
-class IpScramblerModule(private val context: Context) : IIpScramblerModule {
+class IpScramblerModule(private val context: Context) {
+ interface Listener {
+ fun onStatusChanged(newStatus: Status)
+ fun log(message: String)
+ fun onTrafficUpdate(upload: Long, download: Long, read: Long, write: Long)
+ }
+
+ enum class Status {
+ OFF, ON, STARTING, STOPPING, START_DISABLED
+ }
companion object {
const val TAG = "IpScramblerModule"
@@ -221,11 +228,11 @@ class IpScramblerModule(private val context: Context) : IIpScramblerModule {
return if (raw.isEmpty()) raw else raw.slice(1..2)
}
- override fun prepareAndroidVpn(): Intent? {
+ fun prepareAndroidVpn(): Intent? {
return VpnService.prepare(context)
}
- override fun start(enableNotification: Boolean) {
+ fun start(enableNotification: Boolean) {
Prefs.enableNotification(enableNotification)
Prefs.putUseVpn(true)
Prefs.putStartOnBoot(true)
@@ -234,7 +241,7 @@ class IpScramblerModule(private val context: Context) : IIpScramblerModule {
sendIntentToService(OrbotConstants.ACTION_START_VPN)
}
- override fun stop() {
+ fun stop() {
updateStatus(Status.STOPPING)
Prefs.putUseVpn(false)
@@ -261,7 +268,7 @@ class IpScramblerModule(private val context: Context) : IIpScramblerModule {
)
}
- override fun requestStatus() {
+ fun requestStatus() {
if (isServiceRunning()) {
sendIntentToService(OrbotConstants.ACTION_STATUS)
} else {
@@ -269,33 +276,33 @@ class IpScramblerModule(private val context: Context) : IIpScramblerModule {
}
}
- override var appList: Set<String>
+ var appList: Set<String>
get() = getTorifiedApps()
set(value) = saveTorifiedApps(value)
- override var exitCountry: String
+ var exitCountry: String
get() = getExitCountryCode()
set(value) = setExitCountryCode(value)
- override fun getAvailablesLocations(): Set<String> = EXIT_COUNTRY_CODES
+ fun getAvailablesLocations(): Set<String> = EXIT_COUNTRY_CODES
- override var httpProxyPort: Int = -1
+ var httpProxyPort: Int = -1
private set
- override var socksProxyPort: Int = -1
+ var socksProxyPort: Int = -1
private set
- override fun addListener(listener: Listener) {
+ fun addListener(listener: Listener) {
listeners.add(listener)
}
- override fun removeListener(listener: Listener) {
+ fun removeListener(listener: Listener) {
listeners.remove(listener)
}
- override fun clearListeners() {
+ fun clearListeners() {
listeners.clear()
}
- override fun onCleared() {
+ fun onCleared() {
LocalBroadcastManager.getInstance(context).unregisterReceiver(localBroadcastReceiver)
}
}
diff --git a/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt
new file mode 100644
index 0000000..4f80ef4
--- /dev/null
+++ b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt
@@ -0,0 +1,8 @@
+package foundation.e.advancedprivacy.ipscrambler
+
+import org.koin.core.module.dsl.singleOf
+import org.koin.dsl.module
+
+val ipScramblerModule = module {
+ singleOf(::IpScramblerModule)
+}
diff --git a/ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IIpScramblerModule.kt b/ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IIpScramblerModule.kt
deleted file mode 100644
index 859319a..0000000
--- a/ipscrambling/src/main/java/foundation/e/privacymodules/ipscrambler/IIpScramblerModule.kt
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2021 E FOUNDATION
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package foundation.e.privacymodules.ipscrambler
-
-import android.content.Intent
-
-interface IIpScramblerModule {
- fun prepareAndroidVpn(): Intent?
-
- fun start(enableNotification: Boolean = true)
-
- fun stop()
-
- fun requestStatus()
-
- var appList: Set<String>
-
- var exitCountry: String
- fun getAvailablesLocations(): Set<String>
-
- val httpProxyPort: Int
- val socksProxyPort: Int
-
- fun addListener(listener: Listener)
- fun removeListener(listener: Listener)
- fun clearListeners()
-
- fun onCleared()
-
- interface Listener {
- fun onStatusChanged(newStatus: Status)
- fun log(message: String)
- fun onTrafficUpdate(upload: Long, download: Long, read: Long, write: Long)
- }
-
- enum class Status {
- OFF, ON, STARTING, STOPPING, START_DISABLED
- }
-}