Skip to content

Commit

Permalink
add tuic plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Jan 8, 2023
1 parent 18217e0 commit f4bf1ef
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app_tuic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/libs
/html
18 changes: 18 additions & 0 deletions app_tuic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

setupAll()

android {
defaultConfig {
applicationId = "moe.matsuri.exe.tuic"
versionCode = 1
versionName = "0.8.5-1"
splits.abi {
reset()
include("arm64-v8a", "x86_64")
}
}
}
45 changes: 45 additions & 0 deletions app_tuic/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="moe.matsuri.exe.tuic"
android:installLocation="internalOnly"
tools:ignore="MissingLeanbackLauncher">

<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />

<application
android:allowBackup="false"
android:extractNativeLibs="true"
android:label="TUIC Plugin">
<provider
android:name=".BinaryProvider"
android:authorities="moe.matsuri.exe.tuic.BinaryProvider"
android:directBootAware="true"
android:exported="true"
tools:ignore="ExportedContentProvider">
<intent-filter>
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN" />
</intent-filter>
<intent-filter>
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN" />
<data
android:host="moe.matsuri.lite"
android:path="/tuic-plugin"
android:scheme="plugin" />
</intent-filter>

<meta-data
android:name="io.nekohasekai.sagernet.plugin.id"
android:value="tuic-plugin" />
<meta-data
android:name="io.nekohasekai.sagernet.plugin.executable_path"
android:value="libtuic.so" />
</provider>
</application>

</manifest>
23 changes: 23 additions & 0 deletions app_tuic/src/main/java/moe/matsuri/exe/tuic/BinaryProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package moe.matsuri.exe.tuic

import android.net.Uri
import android.os.ParcelFileDescriptor
import io.nekohasekai.sagernet.plugin.NativePluginProvider
import io.nekohasekai.sagernet.plugin.PathProvider
import java.io.File
import java.io.FileNotFoundException

class BinaryProvider : NativePluginProvider() {
override fun populateFiles(provider: PathProvider) {
provider.addPath("tuic-plugin", 0b111101101)
}

override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libtuic.so"
override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) {
"/tuic-plugin" -> ParcelFileDescriptor.open(
File(getExecutable()),
ParcelFileDescriptor.MODE_READ_ONLY
)
else -> throw FileNotFoundException()
}
}
7 changes: 7 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ download_hysteria() {
dl_and_chmod x86_64/libhysteria.so "https://github.com/MatsuriDayo/hysteria/releases/download/$VERSION/hysteria-linux-amd64"
}

download_tuic() {
mkdir_libs "app_tuic/libs"

dl_and_chmod arm64-v8a/libtuic.so "https://github.com/MatsuriDayo/tuic/releases/download/rel/tuic-client-0.8.5-1-aarch64-android"
dl_and_chmod x86_64/libtuic.so "https://github.com/MatsuriDayo/tuic/releases/download/rel/tuic-client-0.8.5-1-x86_64-android"
}

download_"$1"
3 changes: 2 additions & 1 deletion js/make.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set -e

# SN Plugin -> no js build
# moe.matsur.exe.* -> no js build
[ $1 == "hysteria" ] && exit
[ $1 == "tuic" ] && exit

HTML=../app_$1/html
SRC=./plugin_$1
Expand Down
5 changes: 4 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ dependencyResolutionManagement {
rootProject.name = "Matsuri Plugins"

include ':common'

include ':app_xray'
include ':app_brook'
include ':app_hysteria'
include ':app_singbox'

include ':app_hysteria'
include ':app_tuic'

0 comments on commit f4bf1ef

Please sign in to comment.