Skip to content

Commit

Permalink
android: fix an issue causing vpn can't be stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilledheart committed Dec 26, 2023
1 parent 81832f7 commit 28b03ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions android/yass/src/main/java/it/gui/yass/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import androidx.appcompat.app.AppCompatDelegate;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -201,16 +202,21 @@ private void onStartVpn() {
statusTextView.setText(String.format(res.getString(R.string.status_started_with_error_msg), "Unable to run create tunFd"));
return;
}
int fd = tunFd.getFd();
tunFd.detachFd();

tun2proxyThread = new Thread(){
public void run() {
Log.v(TAG, "tun2proxy thr started");
int ret = tun2ProxyStart("socks5://127.0.0.1:3000", fd, vpnService.DEFAULT_MTU, false, true);
int fd = tunFd.getFd();
int ret = tun2ProxyStart("socks5://127.0.0.1:3000", fd, vpnService.DEFAULT_MTU, true, true);
if (ret != 0) {
// TODO should we handle this error?
Log.e(TAG, String.format("Unable to run tun2ProxyStart: %d", ret));
}
try {
tunFd.close();
} catch (IOException e) {
// nop
}
Log.v(TAG, "tun2proxy thr stopped");
}
};
Expand Down
2 changes: 1 addition & 1 deletion third_party/tun2proxy
Submodule tun2proxy updated 1 files
+7 −1 src/android.rs

0 comments on commit 28b03ef

Please sign in to comment.