Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级gost到v3.0.0-alpha.6 #36

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v1
- name: Checkout
uses: actions/checkout@v3
- name: Extract Signature
run: echo ${{secrets.KEY_FILE}} | base64 -d > $HOME/.android.jks
- name: set up JDK 1.8
uses: actions/setup-java@v1
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 1.8
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: ./gradlew assembleRelease
env:
KEY_PASS: ${{secrets.KEY_PASS}}
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: ShadowsocksGostPlugin.apk
path: app/build/outputs/apk/release/app-release.apk
- name: Release Build
uses: meeDamian/github-release@1.0
uses: meeDamian/github-release@2.0
with:
token: ${{secrets.GITHUB_TOKEN}}
draft: true
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<h1 align="center">Looking for maintainer 本项目正在寻求接手维护者</h1>

<h1 align="center">Welcome to Shadowsocks Gost Plugin</h1>
<p>
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/xausky/ShadowsocksGostPlugin/Android CI">
Expand Down Expand Up @@ -29,14 +31,14 @@ Download prebuilt APK here [Release](https://github.com/xausky/ShadowsocksGostPl

## ❗ 注意 Notices

* 使用#SS_HOST参数会先对填写的主机名进行DNS解析后才传递
* 如果是与主机名相关的远程协议比如ws协议必须直接在参数里配置域名
* 在参数里面配置的域名会忽略手机系统的DNS配置固定使用 Public DNS+
* ~使用#SS_HOST参数会先对填写的主机名进行DNS解析后才传递~ 这应该是旧版Shadowsocks-Android才会存在的问题
* ~如果是与主机名相关的远程协议比如ws协议必须直接在参数里配置域名~ 同上
* 在参数里面配置的域名会忽略手机系统的DNS配置,默认使用 Public DNS+解析
* ~如果插件参数里面使用 `-F=` 形式的参数传递则后续参数不能含有 `=` 号,推荐使用 `-F ` 形式代替~ 使用新版配置格式(CFGBLOB)即可避开这个问题

* Host specified by #SS_HOST will be firstly resolved with DNS before being passed on
* If the hostname is tied to the protocol, like WebSocket (ws), you must directly use domain name in configuration parameters
* The domain name(s) appeared in configuration parameters is/are hard-coded to be resolved with Public DNS+, in other words, ignoring the OS's DNS configurations
* ~Host specified by #SS_HOST will be firstly resolved with DNS before being passed on~ Should be a problem specific to older versions of Shadowsocks-Android
* ~If the hostname is tied to the protocol, like WebSocket (ws), you must directly use domain name in configuration parameters~ Same as above
* The domain name(s) appeared in configuration parameters is/are resolved with Public DNS+ by default, in other words, ignoring the OS's DNS configurations
* ~If you configure a parameter in the form of `-F=`, then the subsequent parameters can no longer contain `=`, so it's recommended to use the form of `-F ` instead~ This issue can be avoided simply by using new config format (CFGBLOB)

## ❤ 关注我 Follow me
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 2111
versionName "2.11.1"
versionName "3.0.0-rc.0"
}
signingConfigs {
releaseConfig {
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
Expand All @@ -23,6 +26,7 @@
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.github.shadowsocks.plugin.ConfigurationActivity;
import com.github.shadowsocks.plugin.PluginOptions;
Expand All @@ -31,15 +35,19 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;

public class ConfigActivity extends ConfigurationActivity {
private LinearLayout linearlayout_cmdargs;
Expand Down Expand Up @@ -349,6 +357,7 @@ private void addFileEntry(final String fileName, final String fileData, String h
@SuppressLint("InflateParams") final View child = inflater.inflate(R.layout.fileentry, null);

TextView fileNameLabel = child.findViewById(R.id.text_file_name);
Button button_load = child.findViewById(R.id.button_load);
Button button_del_file = child.findViewById(R.id.button_del_file);
EditText fileDataEditText = child.findViewById(R.id.editText_file_data);

Expand All @@ -364,6 +373,13 @@ private void addFileEntry(final String fileName, final String fileData, String h

fileDataMap.put(fileName, fileDataEditText.getText());

button_load.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
readFromFile(fileName);
}
});

button_del_file.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -374,8 +390,74 @@ public void onClick(View v) {
parent.addView(child);
}

private static final int READ_FROM_FILE = 1;
private String openingFileName = "";
private void readFromFile(String openingFileName) {
if (readFileThread != null && readFileThread.isAlive()) {
showToast(R.string.still_reading);
return;
}
this.openingFileName = openingFileName;
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
String mimeType = "*/*";
if (openingFileName.endsWith(".json"))
mimeType = "application/json";
else if (openingFileName.endsWith(".pem"))
mimeType = "application/x-pem-file";
else if (openingFileName.endsWith(".txt"))
mimeType = "text/plain";
intent.setType(mimeType);
startActivityForResult(intent, READ_FROM_FILE);
}

private Thread readFileThread;
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == READ_FROM_FILE) {
if (data != null) {
final Uri uri = data.getData();
final ContentResolver resolver = this.getContentResolver();
if (readFileThread == null || !readFileThread.isAlive()) {
readFileThread = new Thread() {
@Override
public void run() {
try {
StringBuilder stringBuilder = new StringBuilder();
InputStream inputStream = resolver.openInputStream(uri);
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream)));
char[] buf = new char[4096];
for (int r, t = 0; (r = reader.read(buf)) != -1; t += r) {
if (t > 1024 * 1024) {
showToast(R.string.err_file_too_large);
return;
}
stringBuilder.append(buf, 0, r);
}
final String result = stringBuilder.toString();
runOnUiThread(new Runnable() {
@Override
public void run() {
Editable editable = fileDataMap.get(openingFileName);
if (editable != null) {
editable.clear();
editable.append(result);
}
}
});
} catch (IOException ignored) {}
}
};
readFileThread.start();
} else Log.e("ConfigActivity", "readFileThread is unexpectedly alive");
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}

private final String[] fileNameList = {
"config.json",
"config.yaml",
"cacert.pem",
"clientcert.pem",
"clientcertkey.pem",
Expand Down Expand Up @@ -420,6 +502,18 @@ private void saveUI() throws NullPointerException, JSONException {
}
this.decodedPluginOptions.put("Files", files);

// save DNS server
EditText editText_dns_server = findViewById(R.id.editText_dns_server);
Editable editable_dns_server = editText_dns_server.getText();
String dnsServer = "";
if (editable_dns_server != null) {
dnsServer = editable_dns_server.toString();
}
if (dnsServer.length() == 0) {
dnsServer = getString(R.string.example_dns_server);
}
this.decodedPluginOptions.put("DNSServer", dnsServer);

// save legacyCfg, if there's one
String legacyCfg = "";
EditText editText_legacyCfg = findViewById(R.id.editText_legacyCfg);
Expand Down Expand Up @@ -496,6 +590,17 @@ private void populateUI() throws JSONException {
addFileEntry(fileName, jsonObject.getString(fileName), "", true);
}

// populate dns server
String dnsServer = "";
try {
dnsServer = this.decodedPluginOptions.getString("DNSServer");
} catch (JSONException ignored) {}
if (dnsServer.length() == 0) {
dnsServer = getString(R.string.example_dns_server);
}
EditText editText_dns_server = findViewById(R.id.editText_dns_server);
editText_dns_server.setText(dnsServer);

// populate legacyCfg, if there's one
String legacyCfg = "";
try {
Expand Down
34 changes: 0 additions & 34 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Loading