mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-09 20:11:01 +00:00
1. fix for bug #19
This commit is contained in:
parent
0c5a3b0f82
commit
63dcc3802b
@ -143,24 +143,16 @@ class MainActivity : AppCompatActivity() {
|
||||
ipLayout.visibility = View.VISIBLE
|
||||
findViewById<TextView>(R.id.ip).text = address
|
||||
}
|
||||
/*
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
connectivityManager?.let {
|
||||
it.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onAvailable(network: Network) {
|
||||
if(isStarted) {
|
||||
stopVpn()
|
||||
Thread.sleep(1000)
|
||||
startVpn()
|
||||
}
|
||||
}
|
||||
override fun onLost(network: Network?) {
|
||||
if(isStarted) {
|
||||
stopVpn()
|
||||
Thread.sleep(1000)
|
||||
startVpn()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -171,22 +163,14 @@ class MainActivity : AppCompatActivity() {
|
||||
Log.i(TAG, "Network state has been changed")
|
||||
if ("android.net.conn.CONNECTIVITY_CHANGE" == intent.action) {
|
||||
if (status == NetworkUtils.NETWORK_STATUS_NOT_CONNECTED) {
|
||||
if(isStarted) {
|
||||
stopVpn()
|
||||
Thread.sleep(1000)
|
||||
startVpn()
|
||||
}
|
||||
} else {
|
||||
if(isStarted) {
|
||||
stopVpn()
|
||||
Thread.sleep(1000)
|
||||
startVpn()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
val sourceDir: String = this.applicationInfo.sourceDir
|
||||
val dexFile = DexFile(sourceDir)
|
||||
|
@ -34,14 +34,13 @@ import java.net.URI
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
||||
class PeerListActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
const val PEER_LIST_URL = "https://publicpeers.neilalexander.dev/publicnodes.json"
|
||||
}
|
||||
|
||||
fun downloadJson(link: String): String {
|
||||
private fun downloadJson(link: String): String {
|
||||
URL(link).openStream().use { input ->
|
||||
var outStream = ByteArrayOutputStream()
|
||||
outStream.use { output ->
|
||||
|
@ -31,7 +31,7 @@ import kotlin.concurrent.thread
|
||||
|
||||
class YggdrasilTunService : VpnService() {
|
||||
|
||||
private lateinit var ygg: Yggdrasil
|
||||
//private lateinit var ygg: Yggdrasil
|
||||
private lateinit var tunInputStream: InputStream
|
||||
private lateinit var tunOutputStream: OutputStream
|
||||
private lateinit var address: String
|
||||
@ -43,6 +43,7 @@ class YggdrasilTunService : VpnService() {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Yggdrasil-service"
|
||||
private val ygg = Yggdrasil()
|
||||
}
|
||||
|
||||
private val FOREGROUND_ID = 1338
|
||||
@ -58,7 +59,7 @@ class YggdrasilTunService : VpnService() {
|
||||
val peers = deserializeStringList2PeerInfoSet(intent.getStringArrayListExtra(MainActivity.CURRENT_PEERS))
|
||||
val dns = deserializeStringList2DNSInfoSet(intent.getStringArrayListExtra(MainActivity.CURRENT_DNS))
|
||||
val staticIP: Boolean = intent.getBooleanExtra(MainActivity.STATIC_IP, false)
|
||||
ygg = Yggdrasil()
|
||||
|
||||
setupTunInterface(pi, peers, dns, staticIP)
|
||||
foregroundNotification(FOREGROUND_ID, "Yggdrasil service started")
|
||||
}
|
||||
@ -235,7 +236,7 @@ class YggdrasilTunService : VpnService() {
|
||||
tunOutputStream.close()
|
||||
tunInterface!!.close()
|
||||
Log.d(TAG,"Stop is running from service")
|
||||
ygg.stop()
|
||||
//ygg.stop()
|
||||
val intent: Intent = Intent()
|
||||
pi!!.send(this, MainActivity.STATUS_STOP, intent)
|
||||
stopForeground(true)
|
||||
|
Loading…
Reference in New Issue
Block a user