-
Notifications
You must be signed in to change notification settings - Fork 88
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
1 parent
99e00e8
commit 6f1b356
Showing
47 changed files
with
1,765 additions
and
13 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
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
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,5 @@ | ||
/build | ||
/release | ||
# no tests written yet | ||
/src/androidTest | ||
/src/test |
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,75 @@ | ||
import org.apache.tools.ant.taskdefs.condition.Os | ||
import com.android.build.OutputFile | ||
|
||
import java.util.regex.Matcher | ||
import java.util.regex.Pattern | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
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" | ||
} | ||
} | ||
|
||
def javaVersion = JavaVersion.VERSION_1_8 | ||
|
||
android { | ||
compileSdkVersion 29 | ||
compileOptions { | ||
sourceCompatibility javaVersion | ||
targetCompatibility javaVersion | ||
} | ||
kotlinOptions.jvmTarget = javaVersion | ||
defaultConfig { | ||
minSdkVersion rootProject.minSdkVersion | ||
targetSdkVersion rootProject.sdkVersion | ||
versionCode rootProject.versionCode | ||
versionName rootProject.versionName | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "build/go") | ||
} | ||
|
||
task goBuild(type: Exec) { | ||
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
println "Warning: Building on Windows is not supported" | ||
} else { | ||
executable "/bin/bash" | ||
args "go-build.bash", minSdkVersion | ||
environment "ANDROID_HOME", android.sdkDirectory | ||
environment "ANDROID_NDK_HOME", android.ndkDirectory | ||
} | ||
} | ||
|
||
tasks.whenTaskAdded { task -> | ||
if ((task.name == 'javaPreCompileDebug' || | ||
task.name == 'javaPreCompileRelease')) { | ||
task.dependsOn(goBuild) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.preference:preference:1.1.0' | ||
implementation 'com.github.shadowsocks:plugin:1.3.4' | ||
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" | ||
testImplementation 'junit:junit:4.13' | ||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
} | ||
|
||
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4] | ||
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,30 @@ | ||
#!/bin/bash | ||
|
||
[[ -z "${ANDROID_NDK_HOME}" ]] && ANDROID_NDK_HOME="${ANDROID_HOME}/ndk-bundle" | ||
TOOLCHAIN="$(find ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/* -maxdepth 1 -type d -print -quit)/bin" | ||
ABIS=(armeabi-v7a arm64-v8a x86 x86_64) | ||
GO_ARCHS=('arm GOARM=7' arm64 386 amd64) | ||
CLANG_ARCHS=(armv7a-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android) | ||
STRIP_ARCHS=(arm-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android) | ||
|
||
MIN_API="$1" | ||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
OUT_DIR="$ROOT/build/go" | ||
|
||
cd "$ROOT/src/main/go/v2ray-plugin" | ||
BIN="libv2ray.so" | ||
for i in "${!ABIS[@]}"; do | ||
ABI="${ABIS[$i]}" | ||
[[ -f "${OUT_DIR}/${ABI}/${BIN}" ]] && continue | ||
echo "Build ${BIN} ${ABI}" | ||
mkdir -p ${OUT_DIR}/${ABI} \ | ||
&& env \ | ||
CGO_ENABLED=1 CC="${TOOLCHAIN}/${CLANG_ARCHS[$i]}${MIN_API}-clang" \ | ||
GOOS=android GOARCH=${GO_ARCHS[$i]} \ | ||
go build -v -ldflags='-s -w' -o "${OUT_DIR}/unstripped" \ | ||
&& "${TOOLCHAIN}/${STRIP_ARCHS[$i]}-strip" "${OUT_DIR}/unstripped" -o "${OUT_DIR}/${ABI}/${BIN}" \ | ||
|| exit -1 | ||
rm "${OUT_DIR}/unstripped" | ||
done | ||
|
||
cd "$ROOT" |
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,47 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.github.shadowsocks.plugin.v2ray" | ||
android:installLocation="internalOnly"> | ||
<uses-feature android:name="android.hardware.touchscreen" | ||
android:required="false"/> | ||
<application> | ||
|
||
<provider android:name=".BinaryProvider" | ||
android:exported="true" | ||
android:directBootAware="true" | ||
android:authorities="com.github.shadowsocks.plugin.v2ray.BinaryProvider" | ||
tools:ignore="ExportedContentProvider"> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/> | ||
<data android:scheme="plugin" | ||
android:host="com.github.shadowsocks" | ||
android:path="/v2ray"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/> | ||
<data android:scheme="plugin" | ||
android:host="com.github.shadowsocks" | ||
android:path="/v2ray-plugin"/> | ||
</intent-filter> | ||
<meta-data android:name="com.github.shadowsocks.plugin.id" | ||
android:value="v2ray-plugin"/> | ||
<meta-data android:name="com.github.shadowsocks.plugin.id.aliases" | ||
android:value="v2ray"/> | ||
<meta-data android:name="com.github.shadowsocks.plugin.executable_path" | ||
android:value="libv2ray.so"/> | ||
</provider> | ||
<activity android:name=".ConfigActivity" | ||
android:theme="@style/Theme.Shadowsocks.Immersive"> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<data android:scheme="plugin" | ||
android:host="com.github.shadowsocks" | ||
android:path="/v2ray-plugin"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
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 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/golang:1.13 | ||
working_directory: ~/code | ||
steps: | ||
- checkout | ||
- run: sudo apt-get update && sudo apt-get install -y upx | ||
- restore_cache: | ||
key: go-pkg-{{ checksum "go.sum" }} | ||
- run: ./build-release.sh | ||
- save_cache: | ||
paths: | ||
- /go/pkg | ||
key: go-pkg-{{ checksum "go.sum" }} | ||
- store_artifacts: | ||
path: bin | ||
destination: bin |
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,3 @@ | ||
v2ray-plugin* | ||
/bin/ | ||
/.idea/ |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 by Max Lv <max.c.lv@gmail.com> | ||
Copyright (C) 2019 by Mygod Studio <contact-v2ray-plugin@mygod.be> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,71 @@ | ||
# Yet another SIP003 plugin for shadowsocks, based on v2ray | ||
|
||
[![CircleCI](https://circleci.com/gh/shadowsocks/v2ray-plugin.svg?style=shield)](https://circleci.com/gh/shadowsocks/v2ray-plugin) | ||
[![Releases](https://img.shields.io/github/downloads/shadowsocks/v2ray-plugin/total.svg)](https://github.com/shadowsocks/v2ray-plugin/releases) | ||
[![Language: Go](https://img.shields.io/badge/go-1.12+-blue.svg)](https://github.com/shadowsocks/v2ray-plugin/search?l=go) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/shadowsocks/v2ray-plugin)](https://goreportcard.com/report/github.com/shadowsocks/v2ray-plugin) | ||
[![License](https://img.shields.io/github/license/shadowsocks/v2ray-plugin.svg)](LICENSE) | ||
|
||
## Build | ||
|
||
* `go build` | ||
* Alternatively, you can grab the latest nightly from Circle CI by logging into Circle CI or adding `#artifacts` at the end of URL like such: https://circleci.com/gh/shadowsocks/v2ray-plugin/20#artifacts | ||
|
||
## Usage | ||
|
||
See command line args for advanced usages. | ||
|
||
### Shadowsocks over websocket (HTTP) | ||
|
||
On your server | ||
|
||
```sh | ||
ss-server -c config.json -p 80 --plugin v2ray-plugin --plugin-opts "server" | ||
``` | ||
|
||
On your client | ||
|
||
```sh | ||
ss-local -c config.json -p 80 --plugin v2ray-plugin | ||
``` | ||
|
||
### Shadowsocks over websocket (HTTPS) | ||
|
||
On your server | ||
|
||
```sh | ||
ss-server -c config.json -p 443 --plugin v2ray-plugin --plugin-opts "server;tls;host=mydomain.me" | ||
``` | ||
|
||
On your client | ||
|
||
```sh | ||
ss-local -c config.json -p 443 --plugin v2ray-plugin --plugin-opts "tls;host=mydomain.me" | ||
``` | ||
|
||
### Shadowsocks over quic | ||
|
||
On your server | ||
|
||
```sh | ||
ss-server -c config.json -p 443 --plugin v2ray-plugin --plugin-opts "server;mode=quic;host=mydomain.me" | ||
``` | ||
|
||
On your client | ||
|
||
```sh | ||
ss-local -c config.json -p 443 --plugin v2ray-plugin --plugin-opts "mode=quic;host=mydomain.me" | ||
``` | ||
|
||
### Issue a cert for TLS and QUIC | ||
|
||
v2ray-plugin will look for TLS certificates signed by [acme.sh](https://github.com/Neilpang/acme.sh) by default. | ||
Here's some sample commands for issuing a certificate using CloudFlare. | ||
You can find commands for issuing certificates for other DNS providers at acme.sh. | ||
|
||
```sh | ||
curl https://get.acme.sh | sh | ||
~/.acme.sh/acme.sh --issue --dns dns_cf -d mydomain.me | ||
``` | ||
|
||
Alternatively, you can specify path to your certificates using option `cert` and `key`. |
Oops, something went wrong.