Skip to content

Commit

Permalink
Support QUIC protocol and release v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bongtrop committed Jul 1, 2023
1 parent 4593ce2 commit 080fa36
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 79 deletions.

This file was deleted.

11 changes: 11 additions & 0 deletions app/src/main/assets/all/gost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/system/bin/sh

DIR=$1
SRC=$2
DST=$3
KIND=$4

PATH=$DIR:$PATH

gost $SRC $DST &> $DIR/gost_$KIND.log &
echo "$!" > $DIR/gost_$KIND.pid
10 changes: 0 additions & 10 deletions app/src/main/assets/armeabi-v7a/gost.sh

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/assets/armeabi-v7a/gost_dns.sh

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/assets/x86/gost.sh

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/assets/x86/gost_dns.sh

This file was deleted.

4 changes: 3 additions & 1 deletion app/src/main/java/org/proxydroid/AppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -313,8 +314,9 @@ public static ProxyedApp[] getProxyedApps(Context context, boolean self) {
app.setProxyed(true);
} else app.setProxyed(Arrays.binarySearch(tordApps, app.getUsername()) >= 0);

if (app.isProxyed())
if (app.isProxyed()) {
vectorApps.add(app);
}

}

Expand Down
25 changes: 24 additions & 1 deletion app/src/main/java/org/proxydroid/ProxyDroid.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private void CopyAssets() {
} else {
abi = Build.CPU_ABI;
}
// Copy per arch
try {
if (abi.matches("armeabi-v7a|arm64-v8a"))
files = assetManager.list("armeabi-v7a");
Expand Down Expand Up @@ -211,6 +212,29 @@ private void CopyAssets() {
}
}
}

// Copy for all
try {
files = assetManager.list("all");
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
if (files != null) {
for (String file : files) {
InputStream in;
OutputStream out;
try {
in = assetManager.open("all/" + file);
out = new FileOutputStream(getFilesDir().getAbsolutePath() + "/" + file);
copyFile(in, out);
in.close();
out.flush();
out.close();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
}
}

private void copyFile(InputStream in, OutputStream out) throws IOException {
Expand Down Expand Up @@ -1025,7 +1049,6 @@ private void reset() {

Utils.runRootCommand(
"chmod 700 " + filePath + "/gost.sh\n"
+ "chmod 700 " + filePath + "/gost_dns.sh\n"
+ "chmod 700 " + filePath + "/gost\n");
}

Expand Down
29 changes: 17 additions & 12 deletions app/src/main/java/org/proxydroid/ProxyDroidService.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ public class ProxyDroidService extends Service {

final static String CMD_IPTABLES_REDIRECT_ADD_HTTP = "iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to 8123\n"
+ "iptables -t nat -A OUTPUT -p tcp --dport 443 -j REDIRECT --to 8123\n"
+ "iptables -t nat -A OUTPUT -p tcp --dport 5228 -j REDIRECT --to 8123\n";
+ "iptables -t nat -A OUTPUT -p tcp --dport 5228 -j REDIRECT --to 8123\n"
+ "iptables -t nat -A OUTPUT -p udp --dport 443 -j REDIRECT --to 8124\n"
+ "iptables -t nat -A OUTPUT -p udp --dport 5228 -j REDIRECT --to 8124\n";

final static String CMD_IPTABLES_DNAT_ADD_HTTP = "iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8123\n"
+ "iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:8123\n"
+ "iptables -t nat -A OUTPUT -p tcp --dport 5228 -j DNAT --to-destination 127.0.0.1:8123\n";
+ "iptables -t nat -A OUTPUT -p tcp --dport 5228 -j DNAT --to-destination 127.0.0.1:8123\n"
+ "iptables -t nat -A OUTPUT -p udp --dport 443 -j DNAT --to-destination 127.0.0.1:8124\n"
+ "iptables -t nat -A OUTPUT -p udp --dport 5228 -j DNAT --to-destination 127.0.0.1:8124\n";

final static String CMD_IPTABLES_REDIRECT_ADD_SOCKS = "iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to 8123\n";

Expand Down Expand Up @@ -166,18 +170,20 @@ private void enableProxy() {
final String u = Utils.preserve(user);
final String p = Utils.preserve(password);

String src = "-L=red://127.0.0.1:8123?sniffing=true";
String srcTcp = "-L=red://127.0.0.1:8123?sniffing=true";
String srcUdp = "-L=redu://127.0.0.1:8124?ttl=30s";
String srcDns = "-L=dns://:53/" + dns;
String auth = "";
if (!u.isEmpty() && !p.isEmpty()) {
auth = u + ":" + p + "@";
}
String dst = "-F=" + proxyType + "://" + auth + hostName + ":" + port;
String dstTcp = "-F=" + proxyType + "://" + auth + hostName + ":" + port;
String dstUdp = "-F=relay://" + hostName + ":" + port;

// Start gost here
Utils.runRootCommand(basePath + "gost.sh " + basePath + " " + src + " " + dst);

// Start DNS
Utils.runRootCommand(basePath + "gost_dns.sh " + basePath + " " + dns);
// Start gost tcp here
Utils.runRootCommand(basePath + "gost.sh " + basePath + " " + srcTcp + " " + dstTcp + " " + "tcp");
Utils.runRootCommand(basePath + "gost.sh " + basePath + " " + srcUdp + " " + dstUdp + " " + "udp");
Utils.runRootCommand(basePath + "gost.sh " + basePath + " " + srcDns + " '' " + "dns");

StringBuilder cmd = new StringBuilder();

Expand Down Expand Up @@ -245,7 +251,6 @@ public boolean handleCommand() {

Utils.runRootCommand(
"chmod +x " + basePath + "gost.sh\n"
+ "chmod +x " + basePath + "gost_dns.sh\n"
+ "chmod +x " + basePath + "gost\n");


Expand Down Expand Up @@ -381,8 +386,8 @@ private void onDisconnect() {

sb.append(Utils.getIptables()).append(" -t nat -F OUTPUT\n");

sb.append("kill -9 `cat ").append(basePath).append("gost.pid`\n");

sb.append("kill -9 `cat ").append(basePath).append("gost_tcp.pid`\n");
sb.append("kill -9 `cat ").append(basePath).append("gost_udp.pid`\n");
sb.append("kill -9 `cat ").append(basePath).append("gost_dns.pid`\n");

new Thread() {
Expand Down

0 comments on commit 080fa36

Please sign in to comment.