APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:SSH T PROJECT VPN
版本号:3.1.2
包名称:app.sshtproject

MD5 校验值:d47de9d0b292a5cbd7377502c33607ba

反编译源代码说明

c.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package d5;

import android.text.TextUtils;
import c5.d;
import com.bumptech.glide.e;
import com.bumptech.glide.f;
import com.tencent.mmkv.MMKV;
import com.v2ray.ang.dto.V2rayConfig;
import com.v2ray.ang.service.V2RayVpnService;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import r5.i;
import s5.m;
import s5.p;
import s5.w;
import u3.n;

public abstract class c {

    public static final i f2261a = new i(d.f1422t);

    public static void a(V2rayConfig v2rayConfig) {
        boolean z9;
        String str;
        String e10;
        try {
            MMKV b10 = b();
            boolean z10 = true;
            if (b10 != null && b10.b("pref_fake_dns_enabled")) {
                ArrayList a10 = f.a("geosite:cn");
                MMKV b11 = b();
                String str2 = "";
                if (b11 == null || (str = b11.e("pref_v2ray_routing_agent")) == null) {
                    str = "";
                }
                ArrayList f10 = f(str);
                MMKV b12 = b();
                if (b12 != null && (e10 = b12.e("pref_v2ray_routing_direct")) != null) {
                    str2 = e10;
                }
                ArrayList f11 = f(str2);
                ArrayList<Object> servers = v2rayConfig.getDns().getServers();
                if (servers != null) {
                    servers.add(0, new V2rayConfig.DnsBean.ServersBean("fakedns", null, p.x0(f11, p.x0(f10, a10)), null, null, 26, null));
                }
            }
            List d10 = a.d();
            ArrayList<V2rayConfig.InboundBean> inbounds = v2rayConfig.getInbounds();
            if (!(inbounds instanceof Collection) || !inbounds.isEmpty()) {
                for (V2rayConfig.InboundBean inboundBean : inbounds) {
                    if (e.h(inboundBean.getProtocol(), "dokodemo-door") && e.h(inboundBean.getTag(), "dns-in")) {
                        z9 = false;
                        break;
                    }
                }
            }
            z9 = true;
            if (z9) {
                String str3 = null;
                Boolean bool = null;
                Integer num = null;
                i iVar = a.f2258a;
                v2rayConfig.getInbounds().add(new V2rayConfig.InboundBean("dns-in", 10807, "dokodemo-door", "127.0.0.1", new V2rayConfig.InboundBean.InSettingsBean(str3, bool, num, a.h((String) p.l0(d10)) ? (String) p.l0(d10) : "1.1.1.1", 53, "tcp,udp", 7, null), null, null, null, 192, null));
            }
            ArrayList<V2rayConfig.OutboundBean> outbounds = v2rayConfig.getOutbounds();
            if (!(outbounds instanceof Collection) || !outbounds.isEmpty()) {
                Iterator<T> it = outbounds.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    V2rayConfig.OutboundBean outboundBean = (V2rayConfig.OutboundBean) it.next();
                    if (e.h(outboundBean.getProtocol(), "dns") && e.h(outboundBean.getTag(), "dns-out")) {
                        z10 = false;
                        break;
                    }
                }
            }
            if (z10) {
                v2rayConfig.getOutbounds().add(new V2rayConfig.OutboundBean("dns-out", "dns", null, null, null, null, null, 48, null));
            }
            v2rayConfig.getRouting().getRules().add(0, new V2rayConfig.RoutingBean.RulesBean("field", null, null, "dns-out", null, null, null, null, null, null, f.a("dns-in"), null, null, null, 15346, null));
        } catch (Exception e11) {
            e11.printStackTrace();
        }
    }

    public static MMKV b() {
        return (MMKV) f2261a.getValue();
    }

    public static b c(V2RayVpnService v2RayVpnService, V2rayConfig.OutboundBean outboundBean, String str, String str2, String str3) {
        BufferedReader bufferedReader;
        String str4;
        String str5;
        b bVar;
        MMKV b10;
        boolean z9;
        String str6;
        MMKV b11;
        boolean z10;
        MMKV b12;
        boolean z11;
        V2rayConfig.OutboundBean.OutSettingsBean settings;
        V2rayConfig.OutboundBean.OutSettingsBean.VnextBean.UsersBean usersBean;
        V2rayConfig.OutboundBean.OutSettingsBean settings2;
        V2rayConfig.OutboundBean.OutSettingsBean.ServersBean serversBean;
        V2rayConfig.OutboundBean.OutSettingsBean.VnextBean vnextBean;
        V2rayConfig.OutboundBean.OutSettingsBean.VnextBean vnextBean2;
        List<V2rayConfig.OutboundBean.OutSettingsBean.VnextBean> vnext;
        List<V2rayConfig.OutboundBean.OutSettingsBean.VnextBean> vnext2;
        List<V2rayConfig.OutboundBean.OutSettingsBean.ServersBean> servers;
        List<V2rayConfig.OutboundBean.OutSettingsBean.VnextBean> vnext3;
        V2rayConfig.OutboundBean.OutSettingsBean.VnextBean vnextBean3;
        List<V2rayConfig.OutboundBean.OutSettingsBean.VnextBean.UsersBean> users;
        ArrayList arrayList;
        List d10;
        MMKV b13;
        ArrayList f10;
        Iterator it;
        MMKV b14;
        ArrayList f11;
        MMKV b15;
        String str7;
        List c4;
        ArrayList a10;
        MMKV b16;
        ArrayList f12;
        String e10;
        MMKV b17;
        MMKV b18;
        MMKV b19;
        MMKV b20;
        String str8;
        MMKV b21;
        String str9;
        V2rayConfig.RoutingBean routing;
        String str10;
        String str11;
        List<String> list;
        List<String> list2;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean headerBean;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean requestBean;
        boolean z12;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean.HeadersBean headersBean;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean header;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean request;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings2;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean header2;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings3;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings4;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean header3;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean request2;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean.HeadersBean headers;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings5;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean header4;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean request3;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean tcpSettings6;
        V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean header5;
        boolean z13;
        boolean z14;
        boolean z15;
        V2rayConfig.InboundBean.SniffingBean sniffing;
        ArrayList<String> destOverride;
        V2rayConfig.InboundBean.SniffingBean sniffing2;
        ArrayList<String> destOverride2;
        boolean z16;
        String str12 = "0";
        String str13 = "";
        b bVar2 = new b();
        i iVar = a.f2258a;
        InputStream open = v2RayVpnService.getAssets().open("v2ray_config.json");
        e.l("context.assets.open(fileName)", open);
        InputStreamReader inputStreamReader = new InputStreamReader(open, p8.a.f7434a);
        if (inputStreamReader instanceof BufferedReader) {
            bufferedReader = (BufferedReader) inputStreamReader;
        } else {
            bufferedReader = new BufferedReader(inputStreamReader, 8192);
        }
        try {
            StringWriter stringWriter = new StringWriter();
            char[] cArr = new char[8192];
            while (true) {
                int read = bufferedReader.read(cArr);
                str4 = str12;
                if (read < 0) {
                    break;
                }
                stringWriter.write(cArr, 0, read);
                str12 = str4;
            }
            String stringWriter2 = stringWriter.toString();
            e.l("buffer.toString()", stringWriter2);
            z0.i.d(bufferedReader, null);
            if (TextUtils.isEmpty(stringWriter2)) {
                return bVar2;
            }
            V2rayConfig v2rayConfig = (V2rayConfig) new n().c(stringWriter2, V2rayConfig.class);
            if (v2rayConfig == null) {
                return bVar2;
            }
            try {
                for (V2rayConfig.InboundBean inboundBean : v2rayConfig.getInbounds()) {
                    MMKV b22 = b();
                    if (b22 != null && b22.b("pref_proxy_sharing_enabled")) {
                        z16 = true;
                    } else {
                        z16 = false;
                    }
                    if (!z16) {
                        inboundBean.setListen("127.0.0.1");
                    }
                }
                v2rayConfig.getInbounds().get(0).setPort(10808);
                MMKV b23 = b();
                if (b23 != null) {
                    z13 = b23.b("pref_fake_dns_enabled");
                } else {
                    z13 = false;
                }
                MMKV b24 = b();
                if (b24 != null) {
                    z14 = b24.c("pref_sniffing_enabled");
                } else {
                    z14 = true;
                }
                V2rayConfig.InboundBean.SniffingBean sniffing3 = v2rayConfig.getInbounds().get(0).getSniffing();
                if (sniffing3 != null) {
                    if (!z13 && !z14) {
                        z15 = false;
                        sniffing3.setEnabled(z15);
                    }
                    z15 = true;
                    sniffing3.setEnabled(z15);
                }
                if (!z14 && (sniffing2 = v2rayConfig.getInbounds().get(0).getSniffing()) != null && (destOverride2 = sniffing2.getDestOverride()) != null) {
                    destOverride2.clear();
                }
                if (z13 && (sniffing = v2rayConfig.getInbounds().get(0).getSniffing()) != null && (destOverride = sniffing.getDestOverride()) != null) {
                    destOverride.add("fakedns");
                }
            } catch (Exception e11) {
                e11.printStackTrace();
            }
            try {
                V2rayConfig.OutboundBean.StreamSettingsBean streamSettings = outboundBean.getStreamSettings();
                if (streamSettings != null) {
                    str10 = streamSettings.getNetwork();
                } else {
                    str10 = null;
                }
            } catch (Exception e12) {
                e = e12;
                str5 = "127.0.0.1";
                bVar = bVar2;
            }
            if (e.h(str10, V2rayConfig.DEFAULT_NETWORK)) {
                V2rayConfig.OutboundBean.StreamSettingsBean streamSettings2 = outboundBean.getStreamSettings();
                if (streamSettings2 != null && (tcpSettings6 = streamSettings2.getTcpSettings()) != null && (header5 = tcpSettings6.getHeader()) != null) {
                    str11 = header5.getType();
                } else {
                    str11 = null;
                }
                if (e.h(str11, V2rayConfig.HTTP)) {
                    V2rayConfig.OutboundBean.StreamSettingsBean streamSettings3 = outboundBean.getStreamSettings();
                    if (streamSettings3 != null && (tcpSettings5 = streamSettings3.getTcpSettings()) != null && (header4 = tcpSettings5.getHeader()) != null && (request3 = header4.getRequest()) != null) {
                        list = request3.getPath();
                    } else {
                        list = null;
                    }
                    V2rayConfig.OutboundBean.StreamSettingsBean streamSettings4 = outboundBean.getStreamSettings();
                    if (streamSettings4 != null && (tcpSettings4 = streamSettings4.getTcpSettings()) != null && (header3 = tcpSettings4.getHeader()) != null && (request2 = header3.getRequest()) != null && (headers = request2.getHeaders()) != null) {
                        list2 = headers.getHost();
                    } else {
                        list2 = null;
                    }
                    i iVar2 = new i(d.f1421s);
                    V2rayConfig.OutboundBean.StreamSettingsBean streamSettings5 = outboundBean.getStreamSettings();
                    if (streamSettings5 != null && (tcpSettings3 = streamSettings5.getTcpSettings()) != null) {
                        headerBean = tcpSettings3.getHeader();
                    } else {
                        headerBean = null;
                    }
                    if (headerBean == null) {
                        str5 = "127.0.0.1";
                        bVar = bVar2;
                    } else {
                        bVar = bVar2;
                        try {
                            str5 = "127.0.0.1";
                        } catch (Exception e13) {
                            e = e13;
                            str5 = "127.0.0.1";
                            e.printStackTrace();
                            v2rayConfig.getOutbounds().set(0, outboundBean);
                            b17 = b();
                            if (b17 != null) {
                            }
                            String str14 = "";
                            e(str14, "proxy", v2rayConfig);
                            b18 = b();
                            if (b18 != null) {
                            }
                            String str15 = "";
                            e(str15, "direct", v2rayConfig);
                            b19 = b();
                            if (b19 != null) {
                            }
                            String str16 = "";
                            e(str16, "block", v2rayConfig);
                            V2rayConfig.RoutingBean routing2 = v2rayConfig.getRouting();
                            b20 = b();
                            if (b20 == null) {
                            }
                            if (str8 == null) {
                            }
                            routing2.setDomainStrategy(str8);
                            b21 = b();
                            if (b21 != null) {
                            }
                            str9 = str4;
                            V2rayConfig.RoutingBean.RulesBean rulesBean = new V2rayConfig.RoutingBean.RulesBean("field", null, f.a("domain:googleapis.cn"), "proxy", null, null, null, null, null, null, null, null, null, null, 16370, null);
                            switch (str9.hashCode()) {
                            }
                            b10 = b();
                            if (b10 == null) {
                            }
                            z9 = false;
                            if (z9) {
                            }
                            LinkedHashMap linkedHashMap = new LinkedHashMap();
                            arrayList = new ArrayList();
                            d10 = a.d();
                            b13 = b();
                            if (b13 != null) {
                            }
                            String str17 = "";
                            f10 = f(str17);
                            it = d10.iterator();
                            while (it.hasNext()) {
                            }
                            if (f10.size() > 0) {
                            }
                            b14 = b();
                            if (b14 != null) {
                            }
                            String str18 = "";
                            f11 = f(str18);
                            b15 = b();
                            if (b15 != null) {
                            }
                            str7 = str4;
                            if (f11.size() <= 0) {
                            }
                            c4 = a.c();
                            ArrayList a11 = f.a("geosite:cn");
                            a10 = f.a("geoip:cn");
                            if (f11.size() > 0) {
                            }
                            if (!e.h(str7, "2")) {
                            }
                            arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(c4), 53, a11, a10, null, 16, null));
                            if (a.h((String) p.l0(c4))) {
                            }
                            b16 = b();
                            if (b16 != null) {
                            }
                            f12 = f(str13);
                            if (f12.size() <= 0) {
                            }
                            linkedHashMap.put("domain:googleapis.cn", "googleapis.com");
                            v2rayConfig.setDns(new V2rayConfig.DnsBean(arrayList, linkedHashMap, null, null, null, null, 60, null));
                            i iVar3 = a.f2258a;
                            if (a.h((String) p.l0(d10))) {
                            }
                            b11 = b();
                            if (b11 == null) {
                            }
                            z10 = false;
                            if (z10) {
                            }
                            b12 = b();
                            if (b12 == null) {
                            }
                            z11 = false;
                            if (!z11) {
                            }
                            settings = v2rayConfig.getOutbounds().get(0).getSettings();
                            if (settings == null) {
                            }
                            usersBean = null;
                            if (usersBean != null) {
                            }
                            settings2 = v2rayConfig.getOutbounds().get(0).getSettings();
                            if (settings2 == null) {
                            }
                            serversBean = null;
                            if (serversBean != null) {
                            }
                            if (!e.h(str3, o2.e.V2RAY)) {
                            }
                            b bVar3 = bVar;
                            bVar3.f2259a = true;
                            String prettyPrinting = v2rayConfig.toPrettyPrinting();
                            e.m("<set-?>", prettyPrinting);
                            bVar3.f2260b = prettyPrinting;
                            return bVar3;
                        }
                        try {
                            headerBean.setRequest((V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean) new n().c((String) iVar2.getValue(), V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean.RequestBean.class));
                        } catch (Exception e14) {
                            e = e14;
                            e.printStackTrace();
                            v2rayConfig.getOutbounds().set(0, outboundBean);
                            b17 = b();
                            if (b17 != null) {
                            }
                            String str142 = "";
                            e(str142, "proxy", v2rayConfig);
                            b18 = b();
                            if (b18 != null) {
                            }
                            String str152 = "";
                            e(str152, "direct", v2rayConfig);
                            b19 = b();
                            if (b19 != null) {
                            }
                            String str162 = "";
                            e(str162, "block", v2rayConfig);
                            V2rayConfig.RoutingBean routing22 = v2rayConfig.getRouting();
                            b20 = b();
                            if (b20 == null) {
                            }
                            if (str8 == null) {
                            }
                            routing22.setDomainStrategy(str8);
                            b21 = b();
                            if (b21 != null) {
                            }
                            str9 = str4;
                            V2rayConfig.RoutingBean.RulesBean rulesBean2 = new V2rayConfig.RoutingBean.RulesBean("field", null, f.a("domain:googleapis.cn"), "proxy", null, null, null, null, null, null, null, null, null, null, 16370, null);
                            switch (str9.hashCode()) {
                            }
                            b10 = b();
                            if (b10 == null) {
                            }
                            z9 = false;
                            if (z9) {
                            }
                            LinkedHashMap linkedHashMap2 = new LinkedHashMap();
                            arrayList = new ArrayList();
                            d10 = a.d();
                            b13 = b();
                            if (b13 != null) {
                            }
                            String str172 = "";
                            f10 = f(str172);
                            it = d10.iterator();
                            while (it.hasNext()) {
                            }
                            if (f10.size() > 0) {
                            }
                            b14 = b();
                            if (b14 != null) {
                            }
                            String str182 = "";
                            f11 = f(str182);
                            b15 = b();
                            if (b15 != null) {
                            }
                            str7 = str4;
                            if (f11.size() <= 0) {
                            }
                            c4 = a.c();
                            ArrayList a112 = f.a("geosite:cn");
                            a10 = f.a("geoip:cn");
                            if (f11.size() > 0) {
                            }
                            if (!e.h(str7, "2")) {
                            }
                            arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(c4), 53, a112, a10, null, 16, null));
                            if (a.h((String) p.l0(c4))) {
                            }
                            b16 = b();
                            if (b16 != null) {
                            }
                            f12 = f(str13);
                            if (f12.size() <= 0) {
                            }
                            linkedHashMap2.put("domain:googleapis.cn", "googleapis.com");
                            v2rayConfig.setDns(new V2rayConfig.DnsBean(arrayList, linkedHashMap2, null, null, null, null, 60, null));
                            i iVar32 = a.f2258a;
                            if (a.h((String) p.l0(d10))) {
                            }
                            b11 = b();
                            if (b11 == null) {
                            }
                            z10 = false;
                            if (z10) {
                            }
                            b12 = b();
                            if (b12 == null) {
                            }
                            z11 = false;
                            if (!z11) {
                            }
                            settings = v2rayConfig.getOutbounds().get(0).getSettings();
                            if (settings == null) {
                            }
                            usersBean = null;
                            if (usersBean != null) {
                            }
                            settings2 = v2rayConfig.getOutbounds().get(0).getSettings();
                            if (settings2 == null) {
                            }
                            serversBean = null;
                            if (serversBean != null) {
                            }
                            if (!e.h(str3, o2.e.V2RAY)) {
                            }
                            b bVar32 = bVar;
                            bVar32.f2259a = true;
                            String prettyPrinting2 = v2rayConfig.toPrettyPrinting();
                            e.m("<set-?>", prettyPrinting2);
                            bVar32.f2260b = prettyPrinting2;
                            return bVar32;
                        }
                    }
                    V2rayConfig.OutboundBean.StreamSettingsBean streamSettings6 = outboundBean.getStreamSettings();
                    if (streamSettings6 != null && (tcpSettings2 = streamSettings6.getTcpSettings()) != null && (header2 = tcpSettings2.getHeader()) != null) {
                        requestBean = header2.getRequest();
                    } else {
                        requestBean = null;
                    }
                    if (requestBean != null) {
                        if (list != null && !list.isEmpty()) {
                            z12 = false;
                            if (z12) {
                                list = f.B("/");
                            }
                            requestBean.setPath(list);
                        }
                        z12 = true;
                        if (z12) {
                        }
                        requestBean.setPath(list);
                    }
                    V2rayConfig.OutboundBean.StreamSettingsBean streamSettings7 = outboundBean.getStreamSettings();
                    if (streamSettings7 != null && (tcpSettings = streamSettings7.getTcpSettings()) != null && (header = tcpSettings.getHeader()) != null && (request = header.getRequest()) != null) {
                        headersBean = request.getHeaders();
                    } else {
                        headersBean = null;
                    }
                    if (headersBean != null) {
                        e.j(list2);
                        headersBean.setHost(list2);
                    }
                    v2rayConfig.getOutbounds().set(0, outboundBean);
                    b17 = b();
                    if (b17 != null || (str142 = b17.e("pref_v2ray_routing_agent")) == null) {
                        String str1422 = "";
                    }
                    e(str1422, "proxy", v2rayConfig);
                    b18 = b();
                    if (b18 != null || (str152 = b18.e("pref_v2ray_routing_direct")) == null) {
                        String str1522 = "";
                    }
                    e(str1522, "direct", v2rayConfig);
                    b19 = b();
                    if (b19 != null || (str162 = b19.e("pref_v2ray_routing_blocked")) == null) {
                        String str1622 = "";
                    }
                    e(str1622, "block", v2rayConfig);
                    V2rayConfig.RoutingBean routing222 = v2rayConfig.getRouting();
                    b20 = b();
                    if (b20 == null) {
                        str8 = b20.e("pref_routing_domain_strategy");
                    } else {
                        str8 = null;
                    }
                    if (str8 == null) {
                        str8 = "IPIfNonMatch";
                    }
                    routing222.setDomainStrategy(str8);
                    b21 = b();
                    if (b21 != null || (str9 = b21.e("pref_routing_mode")) == null) {
                        str9 = str4;
                    }
                    V2rayConfig.RoutingBean.RulesBean rulesBean22 = new V2rayConfig.RoutingBean.RulesBean("field", null, f.a("domain:googleapis.cn"), "proxy", null, null, null, null, null, null, null, null, null, null, 16370, null);
                    switch (str9.hashCode()) {
                        case 49:
                            if (str9.equals("1")) {
                                d("ip", "private", v2rayConfig);
                                break;
                            } else {
                                break;
                            }
                        case 50:
                            if (str9.equals("2")) {
                                d("", "cn", v2rayConfig);
                                routing = v2rayConfig.getRouting();
                                routing.getRules().add(0, rulesBean22);
                                break;
                            } else {
                                break;
                            }
                        case 51:
                            if (str9.equals("3")) {
                                d("ip", "private", v2rayConfig);
                                d("", "cn", v2rayConfig);
                                routing = v2rayConfig.getRouting();
                                routing.getRules().add(0, rulesBean22);
                                break;
                            } else {
                                break;
                            }
                    }
                    b10 = b();
                    if (b10 == null && b10.b("pref_fake_dns_enabled")) {
                        z9 = true;
                    } else {
                        z9 = false;
                    }
                    if (z9) {
                        v2rayConfig.setFakedns(f.B(new V2rayConfig.FakednsBean(null, 0, 3, null == true ? 1 : 0)));
                        ArrayList<V2rayConfig.OutboundBean> outbounds = v2rayConfig.getOutbounds();
                        ArrayList arrayList2 = new ArrayList();
                        for (Object obj : outbounds) {
                            if (e.h(((V2rayConfig.OutboundBean) obj).getProtocol(), "freedom")) {
                                arrayList2.add(obj);
                            }
                        }
                        Iterator it2 = arrayList2.iterator();
                        while (it2.hasNext()) {
                            V2rayConfig.OutboundBean.OutSettingsBean settings3 = ((V2rayConfig.OutboundBean) it2.next()).getSettings();
                            if (settings3 != null) {
                                settings3.setDomainStrategy("UseIP");
                            }
                        }
                    }
                    LinkedHashMap linkedHashMap22 = new LinkedHashMap();
                    arrayList = new ArrayList();
                    d10 = a.d();
                    b13 = b();
                    if (b13 != null || (str172 = b13.e("pref_v2ray_routing_agent")) == null) {
                        String str1722 = "";
                    }
                    f10 = f(str1722);
                    it = d10.iterator();
                    while (it.hasNext()) {
                        arrayList.add((String) it.next());
                    }
                    if (f10.size() > 0) {
                        arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(d10), 53, f10, null, null, 16, null));
                    }
                    b14 = b();
                    if (b14 != null || (str182 = b14.e("pref_v2ray_routing_direct")) == null) {
                        String str1822 = "";
                    }
                    f11 = f(str1822);
                    b15 = b();
                    if (b15 != null || (str7 = b15.e("pref_routing_mode")) == null) {
                        str7 = str4;
                    }
                    if (f11.size() <= 0 || e.h(str7, "2") || e.h(str7, "3")) {
                        c4 = a.c();
                        ArrayList a1122 = f.a("geosite:cn");
                        a10 = f.a("geoip:cn");
                        if (f11.size() > 0) {
                            arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(c4), 53, f11, a10, null, 16, null));
                        }
                        if (!e.h(str7, "2") || e.h(str7, "3")) {
                            arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(c4), 53, a1122, a10, null, 16, null));
                        }
                        if (a.h((String) p.l0(c4))) {
                            v2rayConfig.getRouting().getRules().add(0, new V2rayConfig.RoutingBean.RulesBean("field", f.a((String) p.l0(c4)), null, "direct", null, "53", null, null, null, null, null, null, null, null, 16336, null));
                        }
                    }
                    b16 = b();
                    if (b16 != null && (e10 = b16.e("pref_v2ray_routing_blocked")) != null) {
                        str13 = e10;
                    }
                    f12 = f(str13);
                    if (f12.size() <= 0) {
                        ArrayList arrayList3 = new ArrayList(m.b0(f12, 10));
                        Iterator it3 = f12.iterator();
                        while (it3.hasNext()) {
                            str6 = str5;
                            try {
                                arrayList3.add(new r5.e((String) it3.next(), str6));
                                str5 = str6;
                            } catch (Exception e15) {
                                e = e15;
                                e.printStackTrace();
                                b11 = b();
                                if (b11 == null) {
                                }
                                z10 = false;
                                if (z10) {
                                }
                                b12 = b();
                                if (b12 == null) {
                                }
                                z11 = false;
                                if (!z11) {
                                }
                                settings = v2rayConfig.getOutbounds().get(0).getSettings();
                                if (settings == null) {
                                }
                                usersBean = null;
                                if (usersBean != null) {
                                }
                                settings2 = v2rayConfig.getOutbounds().get(0).getSettings();
                                if (settings2 == null) {
                                }
                                serversBean = null;
                                if (serversBean != null) {
                                }
                                if (!e.h(str3, o2.e.V2RAY)) {
                                }
                                b bVar322 = bVar;
                                bVar322.f2259a = true;
                                String prettyPrinting22 = v2rayConfig.toPrettyPrinting();
                                e.m("<set-?>", prettyPrinting22);
                                bVar322.f2260b = prettyPrinting22;
                                return bVar322;
                            }
                        }
                        str6 = str5;
                        w.K0(arrayList3, linkedHashMap22);
                    } else {
                        str6 = str5;
                    }
                    linkedHashMap22.put("domain:googleapis.cn", "googleapis.com");
                    v2rayConfig.setDns(new V2rayConfig.DnsBean(arrayList, linkedHashMap22, null, null, null, null, 60, null));
                    i iVar322 = a.f2258a;
                    if (a.h((String) p.l0(d10))) {
                        v2rayConfig.getRouting().getRules().add(0, new V2rayConfig.RoutingBean.RulesBean("field", f.a((String) p.l0(d10)), null, "proxy", null, "53", null, null, null, null, null, null, null, null, 16336, null));
                    }
                    b11 = b();
                    if (b11 == null && b11.b("pref_local_dns_enabled")) {
                        z10 = true;
                    } else {
                        z10 = false;
                    }
                    if (z10) {
                        a(v2rayConfig);
                    }
                    b12 = b();
                    if (b12 == null && b12.b("pref_speed_enabled")) {
                        z11 = true;
                    } else {
                        z11 = false;
                    }
                    if (!z11) {
                        v2rayConfig.setStats(null);
                        v2rayConfig.setPolicy(null);
                    }
                    settings = v2rayConfig.getOutbounds().get(0).getSettings();
                    if (settings == null && (vnext3 = settings.getVnext()) != null && (vnextBean3 = vnext3.get(0)) != null && (users = vnextBean3.getUsers()) != null) {
                        usersBean = users.get(0);
                    } else {
                        usersBean = null;
                    }
                    if (usersBean != null) {
                        e.j(str);
                        usersBean.setId(str);
                    }
                    settings2 = v2rayConfig.getOutbounds().get(0).getSettings();
                    if (settings2 == null && (servers = settings2.getServers()) != null) {
                        serversBean = servers.get(0);
                    } else {
                        serversBean = null;
                    }
                    if (serversBean != null) {
                        e.j(str2);
                        serversBean.setPassword(str2);
                    }
                    if (!e.h(str3, o2.e.V2RAY)) {
                        V2rayConfig.OutboundBean.OutSettingsBean settings4 = v2rayConfig.getOutbounds().get(0).getSettings();
                        if (settings4 != null && (vnext2 = settings4.getVnext()) != null) {
                            vnextBean = vnext2.get(0);
                        } else {
                            vnextBean = null;
                        }
                        if (vnextBean != null) {
                            vnextBean.setAddress(str6);
                        }
                        V2rayConfig.OutboundBean.OutSettingsBean settings5 = v2rayConfig.getOutbounds().get(0).getSettings();
                        if (settings5 != null && (vnext = settings5.getVnext()) != null) {
                            vnextBean2 = vnext.get(0);
                        } else {
                            vnextBean2 = null;
                        }
                        if (vnextBean2 != null) {
                            vnextBean2.setPort(5502);
                        }
                    }
                    b bVar3222 = bVar;
                    bVar3222.f2259a = true;
                    String prettyPrinting222 = v2rayConfig.toPrettyPrinting();
                    e.m("<set-?>", prettyPrinting222);
                    bVar3222.f2260b = prettyPrinting222;
                    return bVar3222;
                }
            }
            str5 = "127.0.0.1";
            bVar = bVar2;
            v2rayConfig.getOutbounds().set(0, outboundBean);
            b17 = b();
            if (b17 != null) {
            }
            String str14222 = "";
            e(str14222, "proxy", v2rayConfig);
            b18 = b();
            if (b18 != null) {
            }
            String str15222 = "";
            e(str15222, "direct", v2rayConfig);
            b19 = b();
            if (b19 != null) {
            }
            String str16222 = "";
            e(str16222, "block", v2rayConfig);
            V2rayConfig.RoutingBean routing2222 = v2rayConfig.getRouting();
            b20 = b();
            if (b20 == null) {
            }
            if (str8 == null) {
            }
            routing2222.setDomainStrategy(str8);
            b21 = b();
            if (b21 != null) {
            }
            str9 = str4;
            V2rayConfig.RoutingBean.RulesBean rulesBean222 = new V2rayConfig.RoutingBean.RulesBean("field", null, f.a("domain:googleapis.cn"), "proxy", null, null, null, null, null, null, null, null, null, null, 16370, null);
            switch (str9.hashCode()) {
            }
            b10 = b();
            if (b10 == null) {
            }
            z9 = false;
            if (z9) {
            }
            LinkedHashMap linkedHashMap222 = new LinkedHashMap();
            arrayList = new ArrayList();
            d10 = a.d();
            b13 = b();
            if (b13 != null) {
            }
            String str17222 = "";
            f10 = f(str17222);
            it = d10.iterator();
            while (it.hasNext()) {
            }
            if (f10.size() > 0) {
            }
            b14 = b();
            if (b14 != null) {
            }
            String str18222 = "";
            f11 = f(str18222);
            b15 = b();
            if (b15 != null) {
            }
            str7 = str4;
            if (f11.size() <= 0) {
            }
            c4 = a.c();
            ArrayList a11222 = f.a("geosite:cn");
            a10 = f.a("geoip:cn");
            if (f11.size() > 0) {
            }
            if (!e.h(str7, "2")) {
            }
            arrayList.add(new V2rayConfig.DnsBean.ServersBean((String) p.l0(c4), 53, a11222, a10, null, 16, null));
            if (a.h((String) p.l0(c4))) {
            }
            b16 = b();
            if (b16 != null) {
                str13 = e10;
            }
            f12 = f(str13);
            if (f12.size() <= 0) {
            }
            linkedHashMap222.put("domain:googleapis.cn", "googleapis.com");
            v2rayConfig.setDns(new V2rayConfig.DnsBean(arrayList, linkedHashMap222, null, null, null, null, 60, null));
            i iVar3222 = a.f2258a;
            if (a.h((String) p.l0(d10))) {
            }
            b11 = b();
            if (b11 == null) {
            }
            z10 = false;
            if (z10) {
            }
            b12 = b();
            if (b12 == null) {
            }
            z11 = false;
            if (!z11) {
            }
            settings = v2rayConfig.getOutbounds().get(0).getSettings();
            if (settings == null) {
            }
            usersBean = null;
            if (usersBean != null) {
            }
            settings2 = v2rayConfig.getOutbounds().get(0).getSettings();
            if (settings2 == null) {
            }
            serversBean = null;
            if (serversBean != null) {
            }
            if (!e.h(str3, o2.e.V2RAY)) {
            }
            b bVar32222 = bVar;
            bVar32222.f2259a = true;
            String prettyPrinting2222 = v2rayConfig.toPrettyPrinting();
            e.m("<set-?>", prettyPrinting2222);
            bVar32222.f2260b = prettyPrinting2222;
            return bVar32222;
        } finally {
        }
    }

    public static void d(String str, String str2, V2rayConfig v2rayConfig) {
        try {
            if (TextUtils.isEmpty(str2)) {
                return;
            }
            if (e.h(str, "ip") || e.h(str, "")) {
                V2rayConfig.RoutingBean.RulesBean rulesBean = new V2rayConfig.RoutingBean.RulesBean(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 16383, null);
                rulesBean.setType("field");
                rulesBean.setOutboundTag("direct");
                rulesBean.setIp(new ArrayList<>());
                ArrayList<String> ip = rulesBean.getIp();
                if (ip != null) {
                    ip.add("geoip:".concat(str2));
                }
                v2rayConfig.getRouting().getRules().add(rulesBean);
            }
            if (e.h(str, "domain") || e.h(str, "")) {
                V2rayConfig.RoutingBean.RulesBean rulesBean2 = new V2rayConfig.RoutingBean.RulesBean(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 16383, null);
                rulesBean2.setType("field");
                rulesBean2.setOutboundTag("direct");
                rulesBean2.setDomain(new ArrayList<>());
                ArrayList<String> domain = rulesBean2.getDomain();
                if (domain != null) {
                    domain.add("geosite:".concat(str2));
                }
                v2rayConfig.getRouting().getRules().add(rulesBean2);
            }
        } catch (Exception e10) {
            e10.printStackTrace();
        }
    }

    public static void e(String str, String str2, V2rayConfig v2rayConfig) {
        Integer num;
        ArrayList<String> arrayList;
        try {
            if (!TextUtils.isEmpty(str)) {
                V2rayConfig.RoutingBean.RulesBean rulesBean = new V2rayConfig.RoutingBean.RulesBean(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 16383, null);
                rulesBean.setType("field");
                rulesBean.setOutboundTag(str2);
                rulesBean.setDomain(new ArrayList<>());
                V2rayConfig.RoutingBean.RulesBean rulesBean2 = new V2rayConfig.RoutingBean.RulesBean(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 16383, null);
                rulesBean2.setType("field");
                rulesBean2.setOutboundTag(str2);
                rulesBean2.setIp(new ArrayList<>());
                List k12 = p8.m.k1(str, new String[]{","});
                ArrayList arrayList2 = new ArrayList(m.b0(k12, 10));
                Iterator it = k12.iterator();
                while (it.hasNext()) {
                    arrayList2.add(p8.m.u1((String) it.next()).toString());
                }
                Iterator it2 = arrayList2.iterator();
                while (it2.hasNext()) {
                    String str3 = (String) it2.next();
                    if (!a.f(str3)) {
                        boolean z9 = false;
                        if (!p8.m.m1(str3, "geoip:", false)) {
                            if (str3.length() > 0) {
                                z9 = true;
                            }
                            if (z9 && (arrayList = rulesBean.getDomain()) != null) {
                                arrayList.add(str3);
                            }
                        }
                    }
                    arrayList = rulesBean2.getIp();
                    if (arrayList != null) {
                        arrayList.add(str3);
                    }
                }
                ArrayList<String> domain = rulesBean.getDomain();
                Integer num2 = null;
                if (domain != null) {
                    num = Integer.valueOf(domain.size());
                } else {
                    num = null;
                }
                e.j(num);
                if (num.intValue() > 0) {
                    v2rayConfig.getRouting().getRules().add(rulesBean);
                }
                ArrayList<String> ip = rulesBean2.getIp();
                if (ip != null) {
                    num2 = Integer.valueOf(ip.size());
                }
                e.j(num2);
                if (num2.intValue() > 0) {
                    v2rayConfig.getRouting().getRules().add(rulesBean2);
                }
            }
        } catch (Exception e10) {
            e10.printStackTrace();
        }
    }

    public static ArrayList f(String str) {
        ArrayList arrayList = new ArrayList();
        List k12 = p8.m.k1(str, new String[]{","});
        ArrayList arrayList2 = new ArrayList(m.b0(k12, 10));
        Iterator it = k12.iterator();
        while (it.hasNext()) {
            arrayList2.add(p8.m.u1((String) it.next()).toString());
        }
        Iterator it2 = arrayList2.iterator();
        while (it2.hasNext()) {
            String str2 = (String) it2.next();
            if (p8.m.m1(str2, "geosite:", false) || p8.m.m1(str2, "domain:", false)) {
                arrayList.add(str2);
            }
        }
        return arrayList;
    }
}