mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2025-01-22 16:06:30 +00:00
Merge pull request #3 from vikulin/master
Complex update: fix packets flow issues, gradle/libs upgrade
This commit is contained in:
commit
84d624e15c
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@ -10,10 +12,10 @@
|
|||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
<option value="$PROJECT_DIR$/yggdrasil" />
|
<option value="$PROJECT_DIR$/yggdrasil" />
|
||||||
|
<option value="$PROJECT_DIR$/yggdrasil.aar" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="testRunner" value="PLATFORM" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
25
.idea/jarRepositories.xml
generated
Normal file
25
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -1,25 +1,34 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "io.github.chronosx88.yggdrasil"
|
applicationId "io.github.chronosx88.yggdrasil"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
signingConfigs {
|
||||||
|
release {
|
||||||
|
|
||||||
|
storeFile file(KEYSTORE_FILE_PATH)
|
||||||
|
storePassword System.getenv("KEYSTORE_PASSWORD")
|
||||||
|
keyAlias System.getenv("KEY_ALIAS")
|
||||||
|
keyPassword System.getenv("KEY_PASSWORD")
|
||||||
|
}
|
||||||
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ndkVersion "21.2.6472646"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -34,5 +43,5 @@ dependencies {
|
|||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-RC2'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-RC2'
|
||||||
implementation 'com.google.android.material:material:1.1.0-alpha09'
|
implementation 'com.google.android.material:material:1.1.0-alpha09'
|
||||||
implementation 'org.hjson:hjson:3.0.0'
|
implementation 'org.hjson:hjson:3.0.0'
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ fun createNativeYggConfig(config: Config): NodeConfig {
|
|||||||
nativeConfig.adminListen = config.adminListen
|
nativeConfig.adminListen = config.adminListen
|
||||||
nativeConfig.encryptionPrivateKey = config.encryptionPrivateKey
|
nativeConfig.encryptionPrivateKey = config.encryptionPrivateKey
|
||||||
nativeConfig.encryptionPublicKey = config.encryptionPublicKey
|
nativeConfig.encryptionPublicKey = config.encryptionPublicKey
|
||||||
nativeConfig.ifMTU = config.ifMTU
|
//nativeConfig.ifMTU = config.ifMTU
|
||||||
nativeConfig.ifName = config.ifName
|
nativeConfig.ifName = config.ifName
|
||||||
nativeConfig.ifTAPMode = config.ifTAPMode
|
//nativeConfig.ifTAPMode = config.ifTAPMode
|
||||||
nativeConfig.nodeInfoPrivacy = config.nodeInfoPrivacy
|
nativeConfig.nodeInfoPrivacy = config.nodeInfoPrivacy
|
||||||
nativeConfig.signingPrivateKey = config.signingPrivateKey
|
nativeConfig.signingPrivateKey = config.signingPrivateKey
|
||||||
nativeConfig.signingPublicKey = config.signingPublicKey
|
nativeConfig.signingPublicKey = config.signingPublicKey
|
||||||
|
@ -15,11 +15,16 @@ import java.io.FileInputStream
|
|||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
import java.nio.ByteBuffer
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.experimental.or
|
import kotlin.experimental.or
|
||||||
|
|
||||||
|
|
||||||
class YggdrasilTunService : VpnService() {
|
class YggdrasilTunService : VpnService() {
|
||||||
|
|
||||||
|
/** Maximum packet size is constrained by the MTU, which is given as a signed short. */
|
||||||
|
private val MAX_PACKET_SIZE = Short.MAX_VALUE.toInt()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var isRunning: Boolean = false
|
private var isRunning: Boolean = false
|
||||||
}
|
}
|
||||||
@ -56,7 +61,11 @@ class YggdrasilTunService : VpnService() {
|
|||||||
|
|
||||||
tunInterface = builder
|
tunInterface = builder
|
||||||
.addAddress(address, 7)
|
.addAddress(address, 7)
|
||||||
|
.addRoute("10.0.0.0", 8)
|
||||||
|
.addRoute("172.16.0.0", 12)
|
||||||
|
.addRoute("192.168.0.0", 16)
|
||||||
.addRoute("0200::", 7)
|
.addRoute("0200::", 7)
|
||||||
|
.setMtu(MAX_PACKET_SIZE)
|
||||||
.establish()
|
.establish()
|
||||||
|
|
||||||
tunInputStream = FileInputStream(tunInterface!!.fileDescriptor)
|
tunInputStream = FileInputStream(tunInterface!!.fileDescriptor)
|
||||||
@ -75,11 +84,30 @@ class YggdrasilTunService : VpnService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fixConfig(config: MutableMap<Any?, Any?>): MutableMap<Any?, Any?> {
|
private fun fixConfig(config: MutableMap<Any?, Any?>): MutableMap<Any?, Any?> {
|
||||||
|
val peers = arrayListOf<String>();
|
||||||
|
peers.add("tcp://194.177.21.156:5066")
|
||||||
|
peers.add("tcp://46.151.26.194:60575")
|
||||||
|
peers.add("tcp://188.226.125.64:54321")
|
||||||
|
val whiteList = arrayListOf<String>()
|
||||||
|
whiteList.add("")
|
||||||
|
val blackList = arrayListOf<String>()
|
||||||
|
blackList.add("")
|
||||||
|
config["Peers"] = peers
|
||||||
config["Listen"] = ""
|
config["Listen"] = ""
|
||||||
config["AdminListen"] = "tcp://localhost:9001"
|
config["AdminListen"] = "tcp://localhost:9001"
|
||||||
config["IfName"] = "dummy"
|
config["IfName"] = "tun0"
|
||||||
(config["SessionFirewall"] as MutableMap<Any, Any>)["Enable"] = true
|
//config["EncryptionPublicKey"] = "b15633cf66e63a04f03e9d1a5b2ac6411af819cde9e74175cf574d5599b1296c"
|
||||||
(config["SwitchOptions"] as MutableMap<Any, Any>)["MaxTotalQueueSize"] = 1048576
|
//config["EncryptionPrivateKey"] = "a39e2da3ccbb5afc3854574a2e3823e881d2d720754d6fdc877f57b252d3b521"
|
||||||
|
//config["SigningPublicKey"] = "4f248483c094aea370fba86f1630ba5099cb230aa1337ab6ef6ff0b132be2c2b"
|
||||||
|
//config["SigningPrivateKey"] = "e4d56eb2e15e25d9098731e39d661a80c523f31d38b71cbd0ad25a5cde745eac4f248483c094aea370fba86f1630ba5099cb230aa1337ab6ef6ff0b132be2c2b"
|
||||||
|
(config["SessionFirewall"] as MutableMap<Any, Any>)["Enable"] = false
|
||||||
|
//(config["SessionFirewall"] as MutableMap<Any, Any>)["AllowFromDirect"] = true
|
||||||
|
//(config["SessionFirewall"] as MutableMap<Any, Any>)["AllowFromRemote"] = true
|
||||||
|
//(config["SessionFirewall"] as MutableMap<Any, Any>)["AlwaysAllowOutbound"] = true
|
||||||
|
//(config["SessionFirewall"] as MutableMap<Any, Any>)["WhitelistEncryptionPublicKeys"] = whiteList
|
||||||
|
//(config["SessionFirewall"] as MutableMap<Any, Any>)["BlacklistEncryptionPublicKeys"] = blackList
|
||||||
|
|
||||||
|
(config["SwitchOptions"] as MutableMap<Any, Any>)["MaxTotalQueueSize"] = 4194304
|
||||||
if (config["AutoStart"] == null) {
|
if (config["AutoStart"] == null) {
|
||||||
val tmpMap = emptyMap<String, Boolean>().toMutableMap()
|
val tmpMap = emptyMap<String, Boolean>().toMutableMap()
|
||||||
tmpMap["WiFi"] = false
|
tmpMap["WiFi"] = false
|
||||||
@ -91,10 +119,20 @@ class YggdrasilTunService : VpnService() {
|
|||||||
|
|
||||||
private fun readPacketsFromTun() {
|
private fun readPacketsFromTun() {
|
||||||
if(tunInputStream != null) {
|
if(tunInputStream != null) {
|
||||||
val buffer = ByteArray(1024)
|
var packet: ByteArray = ByteArray(MAX_PACKET_SIZE)
|
||||||
tunInputStream!!.read(buffer)
|
// Read the outgoing packet from the input stream.
|
||||||
if (!isBufferEmpty(buffer)) {
|
var length = tunInputStream!!.read(packet)
|
||||||
yggConduitEndpoint.send(buffer)
|
|
||||||
|
//System.out.println("packet size:"+packet.size+" "+byteArrayToHex(packet))
|
||||||
|
//System.out.println("buffer size:"+buffer.array().size+" "+byteArrayToHex(buffer.array()))
|
||||||
|
if (length > 0) {
|
||||||
|
// Ignore control messages, which start with zero.
|
||||||
|
if (packet.get(0).compareTo(0)!=0) {
|
||||||
|
var buffer = ByteBuffer.allocate(length);
|
||||||
|
buffer.put(packet, 0, length)
|
||||||
|
buffer.limit(length)
|
||||||
|
yggConduitEndpoint.send(buffer.array())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,9 +148,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
private fun writePacketsToTun() {
|
private fun writePacketsToTun() {
|
||||||
if(tunOutputStream != null) {
|
if(tunOutputStream != null) {
|
||||||
val buffer = yggConduitEndpoint.recv()
|
val buffer = yggConduitEndpoint.recv()
|
||||||
if (!isBufferEmpty(buffer)) {
|
tunOutputStream!!.write(buffer)
|
||||||
tunOutputStream!!.write(buffer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.41'
|
ext.kotlin_version = '1.3.72'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
classpath 'com.android.tools.build:gradle:4.0.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1536m
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
KEYSTORE_FILE_PATH=/home/vadym/keystore/yggdrasil.jks
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Tue Aug 20 15:25:37 MSK 2019
|
#Tue Jun 09 01:07:00 PDT 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
include ':yggdrasil.aar'
|
||||||
include ':app', ':yggdrasil'
|
include ':app', ':yggdrasil'
|
||||||
|
2
yggdrasil.aar/build.gradle
Normal file
2
yggdrasil.aar/build.gradle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
configurations.maybeCreate("default")
|
||||||
|
artifacts.add("default", file('yggdrasil.aar'))
|
BIN
yggdrasil.aar/yggdrasil.aar
Normal file
BIN
yggdrasil.aar/yggdrasil.aar
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user