-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
525 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,11 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Scala template | ||
*.class | ||
*.log | ||
|
||
# sbt specific | ||
.cache | ||
.history | ||
.lib/ | ||
dist/* | ||
target | ||
lib_managed/ | ||
src_managed/ | ||
project/boot/ | ||
project/plugins/project/ | ||
|
||
# Scala-IDE specific | ||
.scala_dependencies | ||
.worksheet | ||
|
||
# ENSIME specific | ||
.ensime_cache/ | ||
.ensime | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
/out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
### SBT template | ||
# Simple Build Tool | ||
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control | ||
|
||
### Android template | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
src/.deps | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Intellij | ||
.idea/ | ||
proguard-sbt.txt | ||
|
||
# Keystore files | ||
*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
*.iml | ||
.gradle | ||
/.idea | ||
/local.properties | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
|
||
/.deps/ | ||
/src/main/libs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[submodule "src/go"] | ||
path = src/go | ||
path = app/src/go | ||
url = https://github.com/shadowsocks/go.git | ||
branch = shadowsocks | ||
[submodule "src/kcptun"] | ||
path = src/kcptun | ||
path = app/src/kcptun | ||
url = https://github.com/shadowsocks/kcptun.git | ||
branch = shadowsocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/build | ||
# no tests written yet | ||
/src/androidTest | ||
/src/test | ||
/src/bin | ||
/.deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import org.apache.tools.ant.taskdefs.condition.Os | ||
|
||
import java.util.regex.Matcher | ||
import java.util.regex.Pattern | ||
|
||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
def getCurrentFlavor() { | ||
String task = getGradle().getStartParameter().getTaskRequests().toString() | ||
Matcher matcher = Pattern.compile("(assemble|generate)\\w*(Release|Debug)").matcher(task) | ||
if (matcher.find()) return matcher.group(2).toLowerCase() else { | ||
println "Warning: No match found for $task" | ||
return "debug" | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion rootProject.sdkVersion | ||
defaultConfig { | ||
applicationId "com.github.shadowsocks.plugin.kcptun" | ||
minSdkVersion rootProject.minSdkVersion | ||
targetSdkVersion rootProject.sdkVersion | ||
versionCode 10000 | ||
versionName "0.1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "src/bin") | ||
} | ||
|
||
task goBuild(type: Exec) { | ||
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
println "Warning: Building on Windows is not supported" | ||
} else { | ||
executable "sh" | ||
args "-c", "src/make.bash " + minSdkVersion | ||
} | ||
} | ||
|
||
task goClean(type: Exec) { | ||
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
println "Warning: Building on Windows is not supported" | ||
} else { | ||
executable "sh" | ||
args "-c", "src/clean.bash" | ||
} | ||
} | ||
|
||
tasks.whenTaskAdded { task -> | ||
if ((task.name == 'javaPreCompileDebug' || | ||
task.name == 'javaPreCompileRelease')) { | ||
task.dependsOn(goBuild) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion" | ||
implementation 'com.github.shadowsocks:plugin:0.1.1' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.1' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | ||
} | ||
|
||
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3] | ||
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant -> | ||
variant.outputs.each { output -> | ||
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) | ||
if (offset != null) output.versionCodeOverride = variant.versionCode + offset | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
-keepattributes SourceFile,LineNumberTable | ||
-dontobfuscate | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
DEPS=$DIR/.deps | ||
|
||
rm -rf $DEPS | ||
rm -rf $DIR/go/bin | ||
rm -rf $DIR/bin | ||
|
||
echo "Successfully clean kcptun" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/github/shadowsocks/plugin/kcptun/BinaryProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.github.shadowsocks.plugin.kcptun | ||
|
||
import android.net.Uri | ||
import android.os.ParcelFileDescriptor | ||
import com.github.shadowsocks.plugin.NativePluginProvider | ||
import com.github.shadowsocks.plugin.PathProvider | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
|
||
class BinaryProvider : NativePluginProvider() { | ||
override fun populateFiles(provider: PathProvider) { | ||
provider.addPath("kcptun", "755") | ||
} | ||
override fun getExecutable() = context.applicationInfo.nativeLibraryDir + "/libkcptun.so" | ||
override fun openFile(uri: Uri?): ParcelFileDescriptor = when (uri?.path) { | ||
"/kcptun" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY) | ||
else -> throw FileNotFoundException() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/github/shadowsocks/plugin/kcptun/HelpCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.github.shadowsocks.plugin.kcptun | ||
|
||
import com.github.shadowsocks.plugin.PluginOptions | ||
|
||
class HelpCallback : com.github.shadowsocks.plugin.HelpCallback() { | ||
override fun produceHelpMessage(options: PluginOptions): CharSequence = | ||
ProcessBuilder(applicationInfo.nativeLibraryDir + "/libkcptun.so", "--help") | ||
.redirectErrorStream(true) | ||
.start() | ||
.inputStream.bufferedReader().useLines { | ||
it.dropWhile { it != "GLOBAL OPTIONS:" } | ||
.drop(1) | ||
.takeWhile { it.length > 3 } | ||
.filter { | ||
!it.startsWith(" --localaddr ") && | ||
!it.startsWith(" --remoteaddr ") && | ||
!it.startsWith(" -c ") && | ||
!it.startsWith(" -V ") && | ||
!it.startsWith(" --fast-open ") && | ||
!it.startsWith(" --help,") && | ||
!it.startsWith(" --version,") | ||
} | ||
.joinToString("\n") | ||
.replace(Regex(" {2,}"), "\n") | ||
.replace("--", "") | ||
.replace(" value", "=value") | ||
.substring(1) // remove 1st \n | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.