1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-13 04:50:27 +01:00

Fix external proxy not stop after disable

This commit is contained in:
世界 2021-03-27 19:51:09 +08:00
parent d5a13f87e0
commit cadc7b5758
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -32,20 +32,17 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.SerializedData;
import org.telegram.ui.SwipeGestureSettingsView; import org.telegram.ui.SwipeGestureSettingsView;
import java.io.File; import java.io.File;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.ConcurrentHashSet;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import tw.nekomimi.nekogram.ProxyManager; import tw.nekomimi.nekogram.ProxyManager;
@ -62,8 +59,6 @@ import tw.nekomimi.nekogram.utils.UIUtil;
import static com.v2ray.ang.V2RayConfig.SSR_PROTOCOL; import static com.v2ray.ang.V2RayConfig.SSR_PROTOCOL;
import static com.v2ray.ang.V2RayConfig.SS_PROTOCOL; import static com.v2ray.ang.V2RayConfig.SS_PROTOCOL;
import com.google.android.exoplayer2.util.Log;
public class SharedConfig { public class SharedConfig {
public static String pushString = ""; public static String pushString = "";
@ -1631,11 +1626,15 @@ public class SharedConfig {
public static void setCurrentProxy(@Nullable ProxyInfo info) { public static void setCurrentProxy(@Nullable ProxyInfo info) {
if (currentProxy instanceof ExternalSocks5Proxy && !currentProxy.equals(info)) {
((ExternalSocks5Proxy) currentProxy).stop();
}
currentProxy = info; currentProxy = info;
MessagesController.getGlobalMainSettings().edit() MessagesController.getGlobalMainSettings().edit()
.putInt("current_proxy", info == null ? 0 : info.hashCode()) .putInt("current_proxy", info == null ? 0 : info.hashCode())
.commit(); .apply();
setProxyEnable(info != null); setProxyEnable(info != null);