diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index ce1fc4f..ce889bd 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,22 +1,6 @@ - - diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index d3183f2..aa00b2c 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index a5f05cd..e34606c 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -21,5 +21,10 @@ \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index d5d35ec..860da66 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 22d1114..5852d76 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,13 +2,14 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 29 + compileSdkVersion 31 defaultConfig { applicationId "io.github.chronosx88.yggdrasil" minSdkVersion 15 - targetSdkVersion 29 - versionCode 23 - versionName "2.0.3" + targetSdkVersion 31 + + versionCode 36 + versionName "2.0.18" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" setProperty("archivesBaseName", project.getParent().name+"-"+versionName) } @@ -68,19 +69,19 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(path: ':yggdrasil') - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'androidx.preference:preference-ktx:1.1.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8' - implementation 'com.google.android.material:material:1.4.0-rc01' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'com.google.android.material:material:1.5.0-alpha04' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.hbb20:ccp:2.4.0' implementation 'com.vincentbrison.openlibraries.android:dualcache:3.1.1' implementation 'com.vincentbrison.openlibraries.android:dualcache-jsonserializer:3.1.1' testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test:runner:1.3.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/app/src/androidTest/java/io/github/chronosx88/yggdrasil/ExampleInstrumentedTest.kt b/app/src/androidTest/java/org/yggdrasil/app/crispa/ExampleInstrumentedTest.kt similarity index 93% rename from app/src/androidTest/java/io/github/chronosx88/yggdrasil/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/org/yggdrasil/app/crispa/ExampleInstrumentedTest.kt index 3f568e7..24cb359 100644 --- a/app/src/androidTest/java/io/github/chronosx88/yggdrasil/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/org/yggdrasil/app/crispa/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import androidx.test.InstrumentationRegistry import androidx.test.runner.AndroidJUnit4 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 08a84d9..1c87422 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,46 +1,48 @@ + package="org.yggdrasil.app.crispa"> @@ -49,10 +51,11 @@ - + diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/Status.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/models/Status.kt deleted file mode 100644 index ecb73d8..0000000 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/Status.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.chronosx88.yggdrasil.models - -class Status { - var up: Boolean = false -} \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Peer.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Peer.kt deleted file mode 100644 index dd6a0ef..0000000 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Peer.kt +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.chronosx88.yggdrasil.models.config - -import com.google.gson.annotations.SerializedName - -data class Peer ( - //Example [{"PublicKey":[154,201,118,156,19,74,134,115,94,159,76,86,36,192,221,105,220,254,226,161,108,226,17,192,75,243,225,15,42,195,155,2],"Endpoint":"(self)","BytesSent":0,"BytesRecvd":0,"Protocol":"self","Port":0,"Uptime":209900460}] - @SerializedName("Endpoint") var endpoint : String, - @SerializedName("Port") var port : Int, - @SerializedName("Uptime") var uptime : Long, - @SerializedName("Protocol") var protocol : String, - @SerializedName("BytesSent") var bytesSent : Long, - @SerializedName("BytesRecvd") var bytesReceived : Long -) \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/AboutActivity.kt b/app/src/main/java/org/yggdrasil/app/crispa/AboutActivity.kt similarity index 99% rename from app/src/main/java/io/github/chronosx88/yggdrasil/AboutActivity.kt rename to app/src/main/java/org/yggdrasil/app/crispa/AboutActivity.kt index 9d63a91..1f480cd 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/AboutActivity.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/AboutActivity.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.os.Bundle import android.text.Html diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/CopyLocalNodeInfoActivity.kt b/app/src/main/java/org/yggdrasil/app/crispa/CopyLocalNodeInfoActivity.kt similarity index 78% rename from app/src/main/java/io/github/chronosx88/yggdrasil/CopyLocalNodeInfoActivity.kt rename to app/src/main/java/org/yggdrasil/app/crispa/CopyLocalNodeInfoActivity.kt index 2c50ce3..8358659 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/CopyLocalNodeInfoActivity.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/CopyLocalNodeInfoActivity.kt @@ -1,12 +1,12 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.os.Bundle -import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import io.github.chronosx88.yggdrasil.models.config.NodeInfoListAdapter +import org.yggdrasil.app.crispa.models.NodeInfo +import org.yggdrasil.app.crispa.models.config.NodeInfoListAdapter class CopyLocalNodeInfoActivity: AppCompatActivity() { @@ -18,8 +18,8 @@ class CopyLocalNodeInfoActivity: AppCompatActivity() { PreferenceManager.getDefaultSharedPreferences(this.baseContext) val ipv6Address = intent.extras!!.getString(MainActivity.IPv6, "") val publicKey = preferences.getString(MainActivity.publicKey, "") - var nodeInfoListView = findViewById(R.id.nodeInfoList) - val nodeInfoList = listOf(NodeInfo("IP address", ipv6Address!!), NodeInfo("Public Key", publicKey!!)); + var nodeInfoListView = findViewById(R.id.node_info_list) + val nodeInfoList = listOf(NodeInfo("IP address", ipv6Address!!), NodeInfo("Public Key", publicKey!!)); val adapter = NodeInfoListAdapter( this, diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt b/app/src/main/java/org/yggdrasil/app/crispa/DNSListActivity.kt similarity index 92% rename from app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt rename to app/src/main/java/org/yggdrasil/app/crispa/DNSListActivity.kt index 8a464b2..2c468c3 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/DNSListActivity.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.app.Activity import android.content.Intent @@ -9,11 +9,11 @@ import android.widget.* import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import com.google.android.material.floatingactionbutton.FloatingActionButton -import io.github.chronosx88.yggdrasil.models.DNSInfo -import io.github.chronosx88.yggdrasil.models.config.SelectDNSInfoListAdapter -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2DNSInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.ping -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.serializeDNSInfoSet2StringList +import org.yggdrasil.app.crispa.models.DNSInfo +import org.yggdrasil.app.crispa.models.config.SelectDNSInfoListAdapter +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2DNSInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.ping +import org.yggdrasil.app.crispa.models.config.Utils.Companion.serializeDNSInfoSet2StringList import kotlinx.coroutines.* import java.net.InetAddress import kotlin.concurrent.thread diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt b/app/src/main/java/org/yggdrasil/app/crispa/MainActivity.kt similarity index 93% rename from app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt rename to app/src/main/java/org/yggdrasil/app/crispa/MainActivity.kt index 9bf848e..7324dbc 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/MainActivity.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.app.Activity import android.app.ActivityManager @@ -14,17 +14,17 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SwitchCompat import androidx.preference.PreferenceManager import dalvik.system.DexFile -import io.github.chronosx88.yggdrasil.models.DNSInfo -import io.github.chronosx88.yggdrasil.models.PeerInfo -import io.github.chronosx88.yggdrasil.models.config.DNSInfoListAdapter -import io.github.chronosx88.yggdrasil.models.config.PeerInfoListAdapter -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializePeerStringList2PeerInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2DNSInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2PeerInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringSet2DNSInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringSet2PeerInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.serializeDNSInfoSet2StringList -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.serializePeerInfoSet2StringList +import org.yggdrasil.app.crispa.models.DNSInfo +import org.yggdrasil.app.crispa.models.PeerInfo +import org.yggdrasil.app.crispa.models.config.DNSInfoListAdapter +import org.yggdrasil.app.crispa.models.config.PeerInfoListAdapter +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializePeerStringList2PeerInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2DNSInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2PeerInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringSet2DNSInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringSet2PeerInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.serializeDNSInfoSet2StringList +import org.yggdrasil.app.crispa.models.config.Utils.Companion.serializePeerInfoSet2StringList import kotlin.concurrent.thread @@ -398,6 +398,9 @@ class MainActivity : AppCompatActivity() { //TODO reimplement it private fun isYggServiceRunning(context: Context): Boolean { + if(this.intent.hasExtra(YggdrasilTunService.IS_VPN_SERVICE_STOPPED)){ + return !this.intent.getBooleanExtra(YggdrasilTunService.IS_VPN_SERVICE_STOPPED, true) + } val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager for (service in manager.getRunningServices(Int.MAX_VALUE)) { diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt b/app/src/main/java/org/yggdrasil/app/crispa/PeerListActivity.kt similarity index 96% rename from app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt rename to app/src/main/java/org/yggdrasil/app/crispa/PeerListActivity.kt index 3355426..77fd41c 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/PeerListActivity.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.app.Activity import android.content.Intent @@ -21,13 +21,13 @@ import com.hbb20.CCPCountry import com.vincentbrison.openlibraries.android.dualcache.Builder import com.vincentbrison.openlibraries.android.dualcache.SizeOf import com.vincentbrison.openlibraries.android.dualcache.JsonSerializer -import io.github.chronosx88.yggdrasil.models.PeerInfo -import io.github.chronosx88.yggdrasil.models.Status -import io.github.chronosx88.yggdrasil.models.config.DropDownAdapter -import io.github.chronosx88.yggdrasil.models.config.SelectPeerInfoListAdapter -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2PeerInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.ping -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.serializePeerInfoSet2StringList +import org.yggdrasil.app.crispa.models.PeerInfo +import org.yggdrasil.app.crispa.models.Status +import org.yggdrasil.app.crispa.models.config.DropDownAdapter +import org.yggdrasil.app.crispa.models.config.SelectPeerInfoListAdapter +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2PeerInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.ping +import org.yggdrasil.app.crispa.models.config.Utils.Companion.serializePeerInfoSet2StringList import kotlinx.coroutines.* import java.io.ByteArrayOutputStream import java.io.FileNotFoundException diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/Utils.kt b/app/src/main/java/org/yggdrasil/app/crispa/Utils.kt similarity index 88% rename from app/src/main/java/io/github/chronosx88/yggdrasil/Utils.kt rename to app/src/main/java/org/yggdrasil/app/crispa/Utils.kt index 25b62ea..d118246 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/Utils.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/Utils.kt @@ -1,9 +1,9 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.content.Context import com.google.gson.Gson import config.NodeConfig -import io.github.chronosx88.yggdrasil.models.config.Config +import org.yggdrasil.app.crispa.models.config.Config import java.io.File val gson = Gson() diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/YggApplication.kt b/app/src/main/java/org/yggdrasil/app/crispa/YggApplication.kt similarity index 84% rename from app/src/main/java/io/github/chronosx88/yggdrasil/YggApplication.kt rename to app/src/main/java/org/yggdrasil/app/crispa/YggApplication.kt index 67ab86b..d8f9fb4 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggApplication.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/YggApplication.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.app.Application import android.content.Context @@ -9,6 +9,11 @@ import org.acra.ktx.initAcra import org.acra.sender.HttpSender class YggApplication : Application() { + + companion object { + const val ACRA_BACKEND_URL = "http://acrarium.rivchain.org/acrarium-1.4.6/report" + } + override fun attachBaseContext(base: Context) { super.attachBaseContext(base) @@ -18,9 +23,9 @@ class YggApplication : Application() { reportFormat = StringFormat.JSON //each plugin you chose above can be configured in a block like this: httpSender { - uri = "http:///report" - basicAuthLogin="***" - basicAuthPassword = "***" + uri = ACRA_BACKEND_URL + basicAuthLogin="KOF7CEnt5tfTqIhj" + basicAuthPassword = "F4cCIqo9EjpihcPt" httpMethod = HttpSender.Method.POST } dialog { diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt b/app/src/main/java/org/yggdrasil/app/crispa/YggdrasilTunService.kt similarity index 89% rename from app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt rename to app/src/main/java/org/yggdrasil/app/crispa/YggdrasilTunService.kt index b361eb0..290deb2 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/YggdrasilTunService.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import android.app.* import android.content.Context @@ -14,15 +14,16 @@ import androidx.core.app.NotificationCompat import androidx.preference.PreferenceManager import com.google.gson.Gson import com.google.gson.reflect.TypeToken -import io.github.chronosx88.yggdrasil.models.DNSInfo -import io.github.chronosx88.yggdrasil.models.PeerInfo -import io.github.chronosx88.yggdrasil.models.config.Peer -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.convertPeer2PeerStringList -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.convertPeerInfoSet2PeerIdSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2DNSInfoSet -import io.github.chronosx88.yggdrasil.models.config.Utils.Companion.deserializeStringList2PeerInfoSet +import org.yggdrasil.app.crispa.models.DNSInfo +import org.yggdrasil.app.crispa.models.PeerInfo +import org.yggdrasil.app.crispa.models.config.Peer +import org.yggdrasil.app.crispa.models.config.Utils.Companion.convertPeer2PeerStringList +import org.yggdrasil.app.crispa.models.config.Utils.Companion.convertPeerInfoSet2PeerIdSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2DNSInfoSet +import org.yggdrasil.app.crispa.models.config.Utils.Companion.deserializeStringList2PeerInfoSet import mobile.Mobile import mobile.Yggdrasil +import org.acra.ACRA import java.io.* import java.net.Inet6Address import kotlin.concurrent.thread @@ -41,6 +42,7 @@ class YggdrasilTunService : VpnService() { companion object { private const val TAG = "Yggdrasil-service" + public const val IS_VPN_SERVICE_STOPPED = "VPN_STATUS" } private val FOREGROUND_ID = 1338 @@ -139,6 +141,7 @@ class YggdrasilTunService : VpnService() { private fun sendMeshPeerStatus(pi: PendingIntent?){ class Token : TypeToken>() ygg.addressString + ACRA.errorReporter.putCustomData("Peers JSON", ygg.peersJSON) var meshPeers: List = gson.fromJson(ygg.peersJSON, Token().type) val intent: Intent = Intent().putStringArrayListExtra( MainActivity.MESH_PEERS, @@ -161,6 +164,7 @@ class YggdrasilTunService : VpnService() { config["Listen"] = arrayListOf() config["AdminListen"] = "tcp://localhost:9001" config["IfName"] = "tun0" + config["IfMTU"] = 65535 if(staticIP) { val preferences = PreferenceManager.getDefaultSharedPreferences(this.baseContext) @@ -179,12 +183,17 @@ class YggdrasilTunService : VpnService() { config["PublicKey"] = publicKey } } + var multicastInterface = emptyMap().toMutableMap() + multicastInterface["Regex"] = ".*" + multicastInterface["Beacon"] = true + multicastInterface["Listen"] = true + multicastInterface["Port"] = 0 + (config["MulticastInterfaces"] as MutableList)[0] = multicastInterface //(config["SessionFirewall"] as MutableMap)["AllowFromDirect"] = true //(config["SessionFirewall"] as MutableMap)["AllowFromRemote"] = true //(config["SessionFirewall"] as MutableMap)["AlwaysAllowOutbound"] = true //(config["SessionFirewall"] as MutableMap)["WhitelistEncryptionPublicKeys"] = whiteList //(config["SessionFirewall"] as MutableMap)["BlacklistEncryptionPublicKeys"] = blackList - //(config["SwitchOptions"] as MutableMap)["MaxTotalQueueSize"] = 4194304 if (config["AutoStart"] == null) { val tmpMap = emptyMap().toMutableMap() @@ -202,6 +211,8 @@ class YggdrasilTunService : VpnService() { ygg.send(buffer.sliceArray(IntRange(0, length - 1))) } catch (e: IOException) { e.printStackTrace() + } catch (e: Exception){ + e.printStackTrace(); } } @@ -212,6 +223,8 @@ class YggdrasilTunService : VpnService() { tunOutputStream.write(buffer) } catch (e: IOException) { e.printStackTrace() + } catch (e: Exception){ + e.printStackTrace(); } } } @@ -267,6 +280,7 @@ class YggdrasilTunService : VpnService() { "" } var intent = Intent(this, MainActivity::class.java) + intent.putExtra(IS_VPN_SERVICE_STOPPED, isClosed); var stackBuilder = TaskStackBuilder.create(this) stackBuilder.addNextIntentWithParentStack(intent) var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/DNSInfo.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/DNSInfo.kt similarity index 94% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/DNSInfo.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/DNSInfo.kt index 52f4c73..c03cd18 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/DNSInfo.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/DNSInfo.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models +package org.yggdrasil.app.crispa.models import android.content.Context import com.hbb20.CCPCountry diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/NodeInfo.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/NodeInfo.kt similarity index 78% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/NodeInfo.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/NodeInfo.kt index b81462c..c9ea0ee 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/NodeInfo.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/NodeInfo.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models +package org.yggdrasil.app.crispa.models class NodeInfo { diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/PeerInfo.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/PeerInfo.kt similarity index 97% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/PeerInfo.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/PeerInfo.kt index c17a327..b6e2069 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/PeerInfo.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/PeerInfo.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models +package org.yggdrasil.app.crispa.models import android.content.Context import com.hbb20.CCPCountry diff --git a/app/src/main/java/org/yggdrasil/app/crispa/models/Status.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/Status.kt new file mode 100644 index 0000000..42f6056 --- /dev/null +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/Status.kt @@ -0,0 +1,5 @@ +package org.yggdrasil.app.crispa.models + +class Status { + var up: Boolean = false +} \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Config.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Config.kt similarity index 95% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Config.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/Config.kt index 6107b99..b63fa23 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Config.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Config.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DNSInfoListAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/DNSInfoListAdapter.kt similarity index 90% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DNSInfoListAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/DNSInfoListAdapter.kt index 8779dee..f33a1d2 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DNSInfoListAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/DNSInfoListAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.Context import android.view.LayoutInflater @@ -7,8 +7,8 @@ import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.ImageView import android.widget.TextView -import io.github.chronosx88.yggdrasil.R -import io.github.chronosx88.yggdrasil.models.DNSInfo +import org.yggdrasil.app.crispa.R +import org.yggdrasil.app.crispa.models.DNSInfo class DNSInfoListAdapter( diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DropDownAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/DropDownAdapter.kt similarity index 95% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DropDownAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/DropDownAdapter.kt index f98fa33..e67110b 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/DropDownAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/DropDownAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.Context import android.view.LayoutInflater @@ -11,7 +11,7 @@ import android.widget.AdapterView.OnItemClickListener import android.widget.ArrayAdapter import android.widget.PopupWindow import android.widget.TextView -import io.github.chronosx88.yggdrasil.R +import org.yggdrasil.app.crispa.R class DropDownAdapter( diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NetworkUtils.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/NetworkUtils.kt similarity index 96% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NetworkUtils.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/NetworkUtils.kt index 5239389..f84d3ae 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NetworkUtils.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/NetworkUtils.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.Context import android.net.ConnectivityManager diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NodeInfoListAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/NodeInfoListAdapter.kt similarity index 88% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NodeInfoListAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/NodeInfoListAdapter.kt index 8c20a2d..edf17cf 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/NodeInfoListAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/NodeInfoListAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.ClipData import android.content.ClipboardManager @@ -9,9 +9,10 @@ import android.view.ViewGroup import android.widget.TextView import android.widget.Toast import androidx.recyclerview.widget.RecyclerView -import io.github.chronosx88.yggdrasil.R +import org.yggdrasil.app.crispa.R +import org.yggdrasil.app.crispa.models.NodeInfo -class NodeInfoListAdapter(private val context: Context, private val infoSet: Array>) : +class NodeInfoListAdapter(private val context: Context, private val infoSet: Array) : RecyclerView.Adapter() { class ViewHolder(private val context: Context, view: View) : RecyclerView.ViewHolder(view) { @@ -50,8 +51,8 @@ class NodeInfoListAdapter(private val context: Context, private val infoSet: Arr // Get element from your dataset at this position and replace the // contents of the view with that element - viewHolder.key.text = infoSet[position].first - viewHolder.value.text = infoSet[position].second + viewHolder.key.text = infoSet[position].key + viewHolder.value.text = infoSet[position].value } // Return the size of your dataset (invoked by the layout manager) diff --git a/app/src/main/java/org/yggdrasil/app/crispa/models/config/Peer.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Peer.kt new file mode 100644 index 0000000..0f8d240 --- /dev/null +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Peer.kt @@ -0,0 +1,13 @@ +package org.yggdrasil.app.crispa.models.config + +import com.google.gson.annotations.SerializedName + +data class Peer ( + //Example [{"Key":"JQZIX3KIamcp/6S9rycKiAGyg9MK7U6h8UUY5ej36fY=","Root":"AAABERGfllXfKNJshDs/8uzKEIFkFEccE16dmZV/cAo=","Coords":[2,4],"Port":1,"Remote":"tcp://[fe80::5207:4518:4378:7f1%wlan0]:57541","IP":"202:d7cd:bd04:6bbc:acc6:b002:da12:86c7"},{"Key":"DCNBiKAV1xr72JAFUgNrOYfY6Qm/f0Nq6ESZTSLn1eo=","Root":"AAABERGfllXfKNJshDs/8uzKEIFkFEccE16dmZV/cAo=","Coords":[2,4,1],"Port":2,"Remote":"tcp://[fe80::1c39:839:90a5:6ef%wlan0]:1108","IP":"204:7b97:ceeb:fd45:1ca0:84ed:ff55:bf92"}] + @SerializedName("Key") var key : String, + @SerializedName("Root") var root : String, + //@SerializedName("Coords") var uptime : Long, + @SerializedName("Port") var port : Int, + @SerializedName("Remote") var remote : String, + @SerializedName("IP") var ip : String +) \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/PeerInfoListAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/PeerInfoListAdapter.kt similarity index 91% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/PeerInfoListAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/PeerInfoListAdapter.kt index f777eeb..9ae88af 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/PeerInfoListAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/PeerInfoListAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.Context import android.view.LayoutInflater @@ -7,8 +7,8 @@ import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.ImageView import android.widget.TextView -import io.github.chronosx88.yggdrasil.R -import io.github.chronosx88.yggdrasil.models.PeerInfo +import org.yggdrasil.app.crispa.R +import org.yggdrasil.app.crispa.models.PeerInfo class PeerInfoListAdapter( diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectDNSInfoAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectDNSInfoAdapter.kt similarity index 96% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectDNSInfoAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectDNSInfoAdapter.kt index 0b3cf93..78503da 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectDNSInfoAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectDNSInfoAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.ClipData import android.content.ClipboardManager @@ -9,8 +9,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.* -import io.github.chronosx88.yggdrasil.R -import io.github.chronosx88.yggdrasil.models.DNSInfo +import org.yggdrasil.app.crispa.R +import org.yggdrasil.app.crispa.models.DNSInfo class SelectDNSInfoListAdapter( context: Context, diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectPeerInfoListAdapter.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectPeerInfoListAdapter.kt similarity index 96% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectPeerInfoListAdapter.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectPeerInfoListAdapter.kt index 147112c..57ec567 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SelectPeerInfoListAdapter.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SelectPeerInfoListAdapter.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import android.content.ClipData import android.content.ClipboardManager @@ -9,8 +9,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.* -import io.github.chronosx88.yggdrasil.R -import io.github.chronosx88.yggdrasil.models.PeerInfo +import org.yggdrasil.app.crispa.R +import org.yggdrasil.app.crispa.models.PeerInfo class SelectPeerInfoListAdapter( context: Context, diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SessionFirewall.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SessionFirewall.kt similarity index 95% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SessionFirewall.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/SessionFirewall.kt index fc225e1..50bf9fe 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SessionFirewall.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SessionFirewall.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SwitchOptions.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SwitchOptions.kt similarity index 79% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SwitchOptions.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/SwitchOptions.kt index 3893b7c..1ea2c5d 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/SwitchOptions.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/SwitchOptions.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/TunnelRouting.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/TunnelRouting.kt similarity index 95% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/TunnelRouting.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/TunnelRouting.kt index 2386bd4..3addb05 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/TunnelRouting.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/TunnelRouting.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Utils.kt similarity index 79% rename from app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt rename to app/src/main/java/org/yggdrasil/app/crispa/models/config/Utils.kt index 1c737ad..305d1e4 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt +++ b/app/src/main/java/org/yggdrasil/app/crispa/models/config/Utils.kt @@ -1,8 +1,8 @@ -package io.github.chronosx88.yggdrasil.models.config +package org.yggdrasil.app.crispa.models.config import com.google.gson.Gson -import io.github.chronosx88.yggdrasil.models.DNSInfo -import io.github.chronosx88.yggdrasil.models.PeerInfo +import org.yggdrasil.app.crispa.models.DNSInfo +import org.yggdrasil.app.crispa.models.PeerInfo import org.acra.ACRA import java.net.InetAddress import java.net.InetSocketAddress @@ -119,22 +119,18 @@ class Utils { if (list != null) { for(s in list) { var p = gson.fromJson(s, Peer::class.java) - if(p.endpoint == "(self)"){ - out.add(PeerInfo(p.protocol, InetAddress.getByName("localhost"), p.port, null, true)) - } else { - var fixWlanPart = p.endpoint.substring(p.endpoint.indexOf('%'), p.endpoint.indexOf(']')) - var fixedUrlString = p.endpoint.replace(fixWlanPart, "") - var url = URI(fixedUrlString) - out.add( - PeerInfo( - url.scheme, - InetAddress.getByName(url.host), - url.port, - null, - true - ) + var fixWlanPart = p.remote.substring(p.remote.indexOf('%'), p.remote.indexOf(']')) + var fixedUrlString = p.remote.replace(fixWlanPart, "") + var url = URI(fixedUrlString) + out.add( + PeerInfo( + url.scheme, + InetAddress.getByName(url.host), + url.port, + null, + true ) - } + ) } } return out diff --git a/app/src/test/java/io/github/chronosx88/yggdrasil/ExampleUnitTest.kt b/app/src/test/java/org/yggdrasil/app/crispa/ExampleUnitTest.kt similarity index 89% rename from app/src/test/java/io/github/chronosx88/yggdrasil/ExampleUnitTest.kt rename to app/src/test/java/org/yggdrasil/app/crispa/ExampleUnitTest.kt index 462224f..2034cfb 100644 --- a/app/src/test/java/io/github/chronosx88/yggdrasil/ExampleUnitTest.kt +++ b/app/src/test/java/org/yggdrasil/app/crispa/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package io.github.chronosx88.yggdrasil +package org.yggdrasil.app.crispa import org.junit.Test diff --git a/build.gradle b/build.gradle index 6b09d63..6328cd1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.1" + classpath 'com.android.tools.build:gradle:7.0.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f7c3f7..49a62e7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip