-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from segfault-bilibili/master
由 @segfault-bilibili 贡献的一些功能更新
- Loading branch information
Showing
18 changed files
with
1,304 additions
and
264 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 |
---|---|---|
|
@@ -18,6 +18,11 @@ jobs: | |
run: ./gradlew assembleRelease | ||
env: | ||
KEY_PASS: ${{secrets.KEY_PASS}} | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ShadowsocksGostPlugin.apk | ||
path: app/build/outputs/apk/release/app-release.apk | ||
- name: Release Build | ||
uses: meeDamian/[email protected] | ||
with: | ||
|
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 @@ | ||
[submodule "gost"] | ||
path = gost | ||
url = https://github.com/segfault-bilibili/gost.git |
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 |
---|---|---|
@@ -1,28 +1,44 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.github.shadowsocks.plugin.gost"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true"> | ||
<provider android:name=".BinaryProvider" | ||
android:exported="true" | ||
android:authorities="com.github.shadowsocks.plugin.gost.BinaryProvider"> | ||
<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:pathPrefix="/gost"/> | ||
</intent-filter> | ||
<meta-data android:name="com.github.shadowsocks.plugin.id" | ||
android:value="gost"/> | ||
<meta-data android:name="com.github.shadowsocks.plugin.default_config" | ||
android:value="-F ss+mws://chacha20:ss123456@#SS_HOST:#SS_PORT"/> | ||
</provider> | ||
</application> | ||
</manifest> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.github.shadowsocks.plugin.gost"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true"> | ||
<activity | ||
android:name=".ConfigActivity"> | ||
<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="/gost"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<provider | ||
android:name=".BinaryProvider" | ||
android:authorities="com.github.shadowsocks.plugin.gost.BinaryProvider" | ||
android:exported="true"> | ||
<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:host="com.github.shadowsocks" | ||
android:path="/gost" | ||
android:scheme="plugin" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="com.github.shadowsocks.plugin.id" | ||
android:value="gost" /> | ||
</provider> | ||
</application> | ||
|
||
</manifest> |
106 changes: 106 additions & 0 deletions
106
app/src/main/java/com/github/shadowsocks/plugin/gost/Base64.java
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,106 @@ | ||
package com.github.shadowsocks.plugin.gost; | ||
|
||
public class Base64 { | ||
private char paddingChar = '='; | ||
|
||
public void setPaddingChar(char c) throws Base64Exception { | ||
if ( | ||
(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || | ||
(c >= '0' && c <= '9') || | ||
c == '+' || c == '/' | ||
) throw new Base64Exception("INVALID_PADDING_CHAR"); | ||
this.paddingChar = c; | ||
} | ||
|
||
public static class Base64Exception extends Exception { | ||
String msg; | ||
@Override | ||
public String getMessage() { | ||
return this.msg; | ||
} | ||
Base64Exception(String msg) { | ||
this.msg = msg; | ||
} | ||
} | ||
|
||
public byte[] decode(String encoded) throws Base64Exception { | ||
char[] input = new char[encoded.length()]; | ||
encoded.getChars(0, encoded.length(), input, 0); | ||
return this.decode(input); | ||
} | ||
public byte[] decode(char[] input) throws Base64Exception { | ||
if (input.length % 4 != 0) | ||
throw new Base64Exception("BASE64_DECODE_INVALID_LENGTH"); | ||
if (input.length == 0) return new byte[0]; | ||
int endPos = 0; | ||
for (int i = input.length - 1; i >= input.length - 4; i--) { | ||
char c = input[i]; | ||
if ( | ||
(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || | ||
(c >= '0' && c <= '9') || | ||
c == '+' || c == '/' | ||
) { | ||
endPos = i + 1; | ||
break; | ||
} else if (c != this.paddingChar) { | ||
throw new Base64Exception("BASE64_DECODE_INVALID_CHAR"); | ||
} else if (i == input.length - 4) { | ||
throw new Base64Exception("BASE64_DECODE_INVALID_PADDING"); | ||
} | ||
} | ||
int resultLen = (endPos * 6 + 8 - 1) / 8; | ||
byte[] result = new byte[resultLen]; | ||
for (int i = 0, o = 0, buf = 0; i < endPos; i++) { | ||
char c = input[i]; | ||
if (c >= 'A' && c <= 'Z') { | ||
c -= 'A'; | ||
} else if (c >= 'a' && c <= 'z') { | ||
c += 26 - 'a'; | ||
} else if (c >= '0' && c <= '9') { | ||
c += 26 + 26 - '0'; | ||
} else if (c == '+') { | ||
c = 26 + 26 + 10; | ||
} else if (c == '/') { | ||
c = 26 + 26 + 10 + 1; | ||
} else throw new Base64Exception("BASE64_DECODE_INVALID_CHAR"); | ||
buf |= (((int) c) & 0xFF) << (3 - (i % 4)) * 6; | ||
if ((i + 1) % 4 == 0 || i == endPos - 1) { | ||
for (int j = 0; j < 3 && o < resultLen; j++, o++) { | ||
result[o] = (byte) ((buf >> (2 - j) * 8) & 0xFF); | ||
} | ||
buf = 0; | ||
} | ||
} | ||
return result; | ||
} | ||
public String encode(byte[] bin) { | ||
int resultLen = (bin.length * 8 + 6 - 1) / 6; | ||
int outputLen = (resultLen + 4 - 1) / 4; | ||
outputLen *= 4; | ||
char[] output = new char[outputLen]; | ||
for (int i = 0, o = 0, buf = 0; i < bin.length; i++) { | ||
buf |= (((int) bin[i]) & 0xFF) << (2 - (i % 3)) * 8; | ||
if ((i + 1) % 3 == 0 || i == bin.length - 1) { | ||
for (int j = 0; j < 4 && o < resultLen; j++, o++) { | ||
int c = (buf >> (3 - j) * 6) & 0x3F; | ||
if (c < 26) { | ||
output[o] = (char) ('A' + c); | ||
} else if (c < 26 + 26) { | ||
output[o] = (char) ('a' + c - 26); | ||
} else if (c < 26 + 26 + 10) { | ||
output[o] = (char) ('0' + c - (26 + 26)); | ||
} else if (c == 26 + 26 + 10) { | ||
output[o] = '+'; | ||
} else { // always (c == 26 + 26 + 10 + 1) | ||
output[o] = '/'; | ||
} | ||
} | ||
buf = 0; | ||
} | ||
} | ||
for (int i = resultLen; i < outputLen; i++) { | ||
output[i] = this.paddingChar; | ||
} | ||
return new String(output); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
app/src/main/java/com/github/shadowsocks/plugin/gost/BinaryProvider.java
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.