mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a98a47f54d |
@@ -17,7 +17,7 @@ android {
|
||||
|
||||
val versionMajor = 2
|
||||
val versionMinor = 0
|
||||
val versionPatch = 1
|
||||
val versionPatch = 2
|
||||
val versionBuild = 0
|
||||
|
||||
defaultConfig {
|
||||
|
||||
@@ -36,7 +36,7 @@ class BootReceiver : BroadcastReceiver() {
|
||||
Action.START, context,
|
||||
WireGuardConnectivityWatcherService::class.java,
|
||||
mapOf(context.resources.getString(R.string.tunnel_extras_key) to
|
||||
defaultTunnel.id.toString())
|
||||
defaultTunnel.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -6,8 +6,8 @@ import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Context.ACTIVITY_SERVICE
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import com.zaneschepke.wireguardautotunnel.R
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
|
||||
object ServiceTracker {
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -31,7 +31,11 @@ object ServiceTracker {
|
||||
}
|
||||
}
|
||||
intent.component?.javaClass
|
||||
application.startService(intent)
|
||||
try {
|
||||
application.startService(intent)
|
||||
} catch (e : Exception) {
|
||||
e.message?.let { Firebase.crashlytics.log(it) }
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Service> actionOnService(action: Action, context: Context, cls : Class<T>, extras : Map<String,String>? = null) {
|
||||
@@ -43,6 +47,10 @@ object ServiceTracker {
|
||||
}
|
||||
}
|
||||
intent.component?.javaClass
|
||||
context.startService(intent)
|
||||
try {
|
||||
context.startService(intent)
|
||||
} catch (e : Exception) {
|
||||
e.message?.let { Firebase.crashlytics.log(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -161,6 +161,7 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
|
||||
if(!isWifiConnected && vpnService.getState() == Tunnel.State.UP) stopVPN()
|
||||
Timber.d("Lost mobile data connection")
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,6 +201,7 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
|
||||
startVPN()
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-5
@@ -7,6 +7,7 @@ import android.net.Uri
|
||||
import android.provider.OpenableColumns
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.wireguard.config.BadConfigException
|
||||
import com.wireguard.config.Config
|
||||
import com.zaneschepke.wireguardautotunnel.R
|
||||
import com.zaneschepke.wireguardautotunnel.repository.Repository
|
||||
@@ -122,12 +123,18 @@ class MainViewModel @Inject constructor(private val application : Application,
|
||||
val stream = application.applicationContext.contentResolver.openInputStream(uri)
|
||||
stream ?: return
|
||||
val bufferReader = stream.bufferedReader(charset = Charsets.UTF_8)
|
||||
val config = Config.parse(bufferReader)
|
||||
val tunnelName = getNameFromFileName(fileName)
|
||||
viewModelScope.launch {
|
||||
tunnelRepo.save(TunnelConfig(name = tunnelName, wgQuick = config.toWgQuickString()))
|
||||
try {
|
||||
val config = Config.parse(bufferReader)
|
||||
val tunnelName = getNameFromFileName(fileName)
|
||||
viewModelScope.launch {
|
||||
tunnelRepo.save(TunnelConfig(name = tunnelName, wgQuick = config.toWgQuickString()))
|
||||
}
|
||||
stream.close()
|
||||
} catch(_: BadConfigException) {
|
||||
viewModelScope.launch {
|
||||
showSnackBarMessage(application.applicationContext.getString(R.string.bad_config))
|
||||
}
|
||||
}
|
||||
stream.close()
|
||||
}
|
||||
|
||||
@SuppressLint("Range")
|
||||
|
||||
@@ -57,4 +57,5 @@
|
||||
<string name="no_thanks">No thanks</string>
|
||||
<string name="turn_on">Turn on</string>
|
||||
<string name="map">Map</string>
|
||||
<string name="bad_config">Bad config. Please try again.</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user