TopTV v3.0.1版本的 MD5 值为:0fc1b9ce94885bc92edd11a6ee3e5932

以下内容为反编译后的 c.java 源代码,内容仅作参考


package d.a.a.d;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferTable;
import d.a.a.d.e;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Vector;
import me.zhanghai.android.materialprogressbar.BuildConfig;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public class c {
    public Context f29527a;
    public final String[] f29528b = {"config", "tls-server"};
    public final String[] f29529c = {"tls-client", "allow-recursive-routing", "askpass", "auth-nocache", "up", "down", "route-up", "ipchange", "route-pre-down", "auth-user-pass-verify", "block-outside-dns", "client-cert-not-required", "dhcp-release", "dhcp-renew", "dh", "group", "ip-win32", "ifconfig-nowarn", "management-hold", "management", "management-client", "management-query-remote", "management-query-passwords", "management-query-proxy", "management-external-key", "management-forget-disconnect", "management-signal", "management-log-cache", "management-up-down", "management-client-user", "management-client-group", "pause-exit", "preresolve", "plugin", "machine-readable-output", "persist-key", "push", "register-dns", "route-delay", "route-gateway", "route-metric", "route-method", "status", "script-security", "show-net-up", "suppress-timestamps", "tap-sleep", "tmp-dir", "tun-ipv6", "topology", "user", "win-sys"};
    public final String[][] f29530d = {new String[]{"setenv", "IV_GUI_VER"}, new String[]{"setenv", "IV_SSO"}, new String[]{"setenv", "IV_PLAT_VER"}, new String[]{"setenv", "IV_OPENVPN_GUI_VERSION"}, new String[]{"engine", "dynamic"}, new String[]{"setenv", "CLIENT_CERT"}, new String[]{"resolv-retry", "60"}};
    public final String[] f29531e;
    public HashSet<String> f29532f;
    public HashMap<String, Vector<Vector<String>>> f29533g;
    public HashMap<String, Vector<String>> f29534h;
    public String f29535i;

    public static class a extends Exception {
        public a(String str) {
            super(str);
        }
    }

    public enum b {
        initial,
        readin_single_quote,
        reading_quoted,
        reading_unquoted,
        done
    }

    public c() {
        String[] strArr = {"local", "remote", "float", IjkMediaPlayer.OnNativeInvokeListener.ARG_PORT, "connect-retry", "connect-timeout", "connect-retry-max", "link-mtu", "tun-mtu", "tun-mtu-extra", "fragment", "mtu-disc", "local-port", "remote-port", "bind", "nobind", "proto", "http-proxy", "http-proxy-retry", "http-proxy-timeout", "http-proxy-option", "socks-proxy", "socks-proxy-retry", "http-proxy-user-pass", "explicit-exit-notify"};
        this.f29531e = strArr;
        this.f29532f = new HashSet<>(Arrays.asList(strArr));
        this.f29533g = new HashMap<>();
        this.f29534h = new HashMap<>();
    }

    public static void u(e eVar, String str) {
        String[] split = d.a.a.a.m(str).split("\n");
        if (split.length >= 2) {
            eVar.f29547m = split[0];
            eVar.f29548n = split[1];
            eVar.f29546l = true;
        }
    }

    public static void v(d.a.a.a aVar, String str) {
        String[] split = d.a.a.a.m(str).split("\n");
        if (split.length >= 2) {
            aVar.D = split[0];
            aVar.C = split[1];
        }
    }

    public final void a(String str, Vector<String> vector) {
        String trim = vector.get(0).trim();
        String trim2 = vector.get(1).trim();
        File file = new File(str);
        try {
            if (file.exists()) {
                trim.substring(1, trim.length() - 1);
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                String str2 = BuildConfig.FLAVOR;
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    str2 = (str2 + readLine) + "\n";
                }
                if (str2.endsWith("\n")) {
                    str2 = str2.substring(0, str2.length() - 1);
                }
                vector.clear();
                vector.add("ca");
                vector.add("[[NAME]]" + trim2 + "[[INLINE]]" + str2);
            }
        } catch (Exception e2) {
            Log.d(BuildConfig.FLAVOR, BuildConfig.FLAVOR + e2);
        }
    }

    public final void b(d.a.a.a aVar) {
        String[] strArr;
        Iterator<Vector<Vector<String>>> it;
        boolean z = false;
        for (String str : this.f29528b) {
            if (this.f29533g.containsKey(str)) {
                throw new a(String.format("Unsupported Option %s encountered in config file. Aborting", str));
            }
        }
        for (String str2 : this.f29529c) {
            this.f29533g.remove(str2);
        }
        for (Vector<Vector<String>> vector : this.f29533g.values()) {
            Iterator<Vector<String>> it2 = vector.iterator();
            while (it2.hasNext()) {
                if (!k(it2.next())) {
                    z = true;
                }
            }
        }
        if (z) {
            aVar.I = "# These options found in the config file do not map to config settings:\n" + aVar.I;
            while (this.f29533g.values().iterator().hasNext()) {
                aVar.I += j(it.next());
            }
            aVar.H = true;
        }
    }

    public final void c(d.a.a.a aVar, Vector<Vector<String>> vector, boolean z) {
        boolean z2 = false;
        if (z) {
            Iterator<Vector<String>> it = vector.iterator();
            boolean z3 = false;
            while (it.hasNext()) {
                Vector<String> next = it.next();
                for (int i2 = 1; i2 < next.size(); i2++) {
                    if (next.get(i2).equals("block-local")) {
                        aVar.X = false;
                    } else if (next.get(i2).equals("unblock-local")) {
                        aVar.X = true;
                    } else if (next.get(i2).equals("!ipv4")) {
                        z3 = true;
                    } else if (next.get(i2).equals("ipv6")) {
                        aVar.M = true;
                    }
                }
            }
            z2 = z3;
        }
        if (!z || z2) {
            return;
        }
        aVar.w = true;
    }

    public final void d(Vector<String> vector, BufferedReader bufferedReader) {
        String trim = vector.get(0).trim();
        if (!trim.startsWith("<") || !trim.endsWith(">")) {
            return;
        }
        String substring = trim.substring(1, trim.length() - 1);
        String format = String.format("</%s>", substring);
        String str = "[[INLINE]]";
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                throw new a(String.format("No endtag </%s> for starttag <%s> found", substring, substring));
            }
            if (readLine.trim().equals(format)) {
                if (str.endsWith("\n")) {
                    str = str.substring(0, str.length() - 1);
                }
                vector.clear();
                vector.add(substring);
                vector.add(str);
                return;
            }
            str = (str + readLine) + "\n";
        }
    }

    public final void e(Vector<String> vector, BufferedReader bufferedReader, String str, String str2) {
        String trim = vector.get(0).trim();
        if (!trim.startsWith("<") || !trim.endsWith(">")) {
            if (trim.equals("ca")) {
                String trim2 = vector.get(1).trim();
                a(trim2 != null ? str.replaceAll(str2, trim2) : BuildConfig.FLAVOR, vector);
                return;
            }
            return;
        }
        String substring = trim.substring(1, trim.length() - 1);
        String format = String.format("</%s>", substring);
        String str3 = "[[INLINE]]";
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                throw new a(String.format("No endtag </%s> for starttag <%s> found", substring, substring));
            }
            if (readLine.trim().equals(format)) {
                if (str3.endsWith("\n")) {
                    str3 = str3.substring(0, str3.length() - 1);
                }
                vector.clear();
                vector.add(substring);
                vector.add(str3);
                return;
            }
            str3 = (str3 + readLine) + "\n";
        }
    }

    public d.a.a.a f() {
        boolean z;
        StringBuilder sb;
        String str;
        Vector<String> i2;
        Vector<String> i3;
        Vector<Vector<String>> h2;
        Vector<String> i4;
        Vector<String> i5;
        Vector<String> i6;
        int i7;
        Vector<String> i8;
        int i9;
        Vector<String> i10;
        Vector<String> i11;
        Vector<String> i12;
        Vector<String> i13;
        Vector<String> i14;
        Vector<Vector<String>> h3;
        Vector<String> i15;
        Vector<String> i16;
        int i17;
        Vector<String> i18;
        Vector<Vector<String>> h4;
        Vector<String> i19;
        Vector<String> vector;
        boolean z2;
        e[] eVarArr;
        StringBuilder sb2;
        String str2;
        Iterator<Vector<String>> it;
        d.a.a.a aVar = new d.a.a.a("converted Profile");
        aVar.f();
        if (this.f29533g.containsKey("client") || this.f29533g.containsKey("pull")) {
            aVar.x = true;
            this.f29533g.remove("pull");
            this.f29533g.remove("client");
        }
        int i20 = 2;
        Vector<String> i21 = i("secret", 1, 2);
        int i22 = 4;
        int i23 = 3;
        if (i21 != null) {
            aVar.f29500e = 4;
            aVar.p = true;
            aVar.f29505j = i21.get(1);
            if (i21.size() == 3) {
                aVar.f29504i = i21.get(2);
            }
            z = false;
        } else {
            z = true;
        }
        Vector<Vector<String>> h5 = h("route", 1, 4);
        String str3 = BuildConfig.FLAVOR;
        if (h5 != null) {
            Iterator<Vector<String>> it2 = h5.iterator();
            String str4 = BuildConfig.FLAVOR;
            String str5 = str4;
            while (it2.hasNext()) {
                Vector<String> next = it2.next();
                String str6 = next.size() >= i23 ? next.get(i20) : "255.255.255.255";
                String str7 = next.size() >= 4 ? next.get(i23) : "vpn_gateway";
                try {
                    d.a.a.d.b bVar = new d.a.a.d.b(next.get(1), str6);
                    if (str7.equals("net_gateway")) {
                        str5 = str5 + bVar.toString() + " ";
                    } else {
                        str4 = str4 + bVar.toString() + " ";
                    }
                    i20 = 2;
                    i23 = 3;
                } catch (ArrayIndexOutOfBoundsException unused) {
                    throw new a("Could not parse netmask of route " + str6);
                } catch (NumberFormatException unused2) {
                    throw new a("Could not parse netmask of route " + str6);
                }
            }
            aVar.y = str4;
            aVar.Y = str5;
        }
        Vector<Vector<String>> h6 = h("route-ipv6", 1, 4);
        if (h6 != null) {
            while (h6.iterator().hasNext()) {
                str3 = str3 + it.next().get(1) + " ";
            }
            aVar.N = str3;
        }
        if (i("route-nopull", 0, 0) != null) {
            aVar.E = true;
        }
        Vector<Vector<String>> h7 = h("tls-auth", 1, 2);
        if (h7 != null) {
            Iterator<Vector<String>> it3 = h7.iterator();
            while (it3.hasNext()) {
                Vector<String> next2 = it3.next();
                if (next2 != null) {
                    if (!next2.get(1).equals("[inline]")) {
                        aVar.f29505j = next2.get(1);
                        aVar.p = true;
                    }
                    if (next2.size() == 3) {
                        aVar.f29504i = next2.get(2);
                    }
                }
            }
        }
        Vector<String> i24 = i("key-direction", 1, 1);
        if (i24 != null) {
            aVar.f29504i = i24.get(1);
        }
        String[] strArr = {"tls-crypt", "tls-crypt-v2"};
        int i25 = 0;
        for (int i26 = 2; i25 < i26; i26 = 2) {
            String str8 = strArr[i25];
            Vector<String> i27 = i(str8, 1, 1);
            if (i27 != null) {
                aVar.p = true;
                aVar.f29505j = i27.get(1);
                aVar.f29504i = str8;
            }
            i25++;
        }
        Vector<Vector<String>> h8 = h("redirect-gateway", 0, 7);
        if (h8 != null) {
            c(aVar, h8, true);
        }
        Vector<Vector<String>> h9 = h("redirect-private", 0, 5);
        if (h9 != null) {
            c(aVar, h9, false);
        }
        Vector<String> i28 = i("dev", 1, 1);
        Vector<String> i29 = i("dev-type", 1, 1);
        if ((i29 == null || !i29.get(1).equals("tun")) && ((i28 == null || !i28.get(1).startsWith("tun")) && !(i29 == null && i28 == null))) {
            throw new a("Sorry. Only tun mode is supported. See the FAQ for more detail");
        }
        Vector<String> i30 = i("mssfix", 0, 2);
        if (i30 != null) {
            if (i30.size() >= 2) {
                try {
                    aVar.Z = Integer.parseInt(i30.get(1));
                } catch (NumberFormatException unused3) {
                    throw new a("Argument to --mssfix has to be an integer");
                }
            } else {
                aVar.Z = 1450;
            }
            if (i30.size() >= 3 && !i30.get(2).equals("mtu")) {
                throw new a("Second argument to --mssfix unkonwn");
            }
        }
        Vector<String> i31 = i("tun-mtu", 1, 1);
        if (i31 != null) {
            try {
                aVar.o0 = Integer.parseInt(i31.get(1));
            } catch (NumberFormatException unused4) {
                throw new a("Argument to --tun-mtu has to be an integer");
            }
        }
        Vector<String> i32 = i("mode", 1, 1);
        if (i32 == null || i32.get(1).equals("p2p")) {
            int i33 = 2;
            Vector<Vector<String>> h10 = h("dhcp-option", 2, 2);
            if (h10 != null) {
                Iterator<Vector<String>> it4 = h10.iterator();
                while (it4.hasNext()) {
                    Vector<String> next3 = it4.next();
                    String str9 = next3.get(1);
                    String str10 = next3.get(i33);
                    if (str9.equals("DOMAIN")) {
                        aVar.v = next3.get(i33);
                    } else if (str9.equals("DNS")) {
                        aVar.u = true;
                        if (aVar.q.equals(d.a.a.a.f29497b)) {
                            aVar.q = str10;
                        } else {
                            aVar.r = str10;
                        }
                    }
                    i33 = 2;
                }
            }
            Vector<String> i34 = i("ifconfig", 2, 2);
            if (i34 != null) {
                try {
                    aVar.s = new d.a.a.d.b(i34.get(1), i34.get(2)).toString();
                } catch (NumberFormatException e2) {
                    throw new a("Could not pase ifconfig IP address: " + e2.getLocalizedMessage());
                }
            }
            if (i("remote-random-hostname", 0, 0) != null) {
                aVar.F = true;
            }
            if (i("float", 0, 0) != null) {
                aVar.G = true;
            }
            if (i("comp-lzo", 0, 1) != null) {
                aVar.f29508m = true;
            }
            Vector<String> i35 = i("ncp-ciphers", 1, 1);
            Vector<String> i36 = i("data-ciphers", 1, 1);
            Vector<String> i37 = i("cipher", 1, 1);
            if (i37 != null) {
                aVar.K = i37.get(1);
            }
            if (i36 != null) {
                i35 = i36;
            }
            if (i35 == null) {
                if (!TextUtils.isEmpty(aVar.K) && !aVar.K.equals("AES-128-GCM") && !aVar.K.equals("AES-256")) {
                    sb = new StringBuilder();
                    sb.append(aVar.z0);
                    str = "AES-256-GCM:AES-128-GCM:";
                    sb.append(str);
                    sb.append(aVar.K);
                    aVar.z0 = sb.toString();
                }
                i2 = i("auth", 1, 1);
                if (i2 != null) {
                }
                i3 = i("ca", 1, 1);
                if (i3 != null) {
                }
                h2 = h("peer-fingerprint", 1, 1);
                if (h2 != null) {
                }
                i4 = i("cert", 1, 1);
                if (i4 != null) {
                }
                i5 = i(TransferTable.COLUMN_KEY, 1, 1);
                if (i5 != null) {
                }
                i6 = i("pkcs12", 1, 1);
                if (i6 == null) {
                }
                if (i("cryptoapicert", 1, 1) != null) {
                }
                Vector<String> i38 = i("compat-names", 1, i7);
                Vector<String> i39 = i("no-name-remapping", 1, 1);
                i8 = i("tls-remote", 1, 1);
                if (i8 == null) {
                }
                i10 = i("verify-x509-name", 1, i9);
                if (i10 != null) {
                }
                i11 = i("x509-username-field", 1, 1);
                if (i11 != null) {
                }
                i12 = i("verb", 1, 1);
                if (i12 != null) {
                }
                if (i("nobind", 0, 0) != null) {
                }
                if (i("persist-tun", 0, 0) != null) {
                }
                if (i("push-peer-info", 0, 0) != null) {
                }
                i13 = i("connect-retry", 1, 2);
                if (i13 != null) {
                }
                i14 = i("connect-retry-max", 1, 1);
                if (i14 != null) {
                }
                h3 = h("remote-cert-tls", 1, 1);
                if (h3 != null) {
                }
                i15 = i("auth-user-pass", 0, 1);
                if (i15 != null) {
                }
                i16 = i("auth-retry", 1, 1);
                if (i16 != null) {
                }
                i17 = 2;
                i18 = i("crl-verify", 1, i17);
                if (i18 != null) {
                }
                a.i.q.e<e, e[]> q = q(null);
                aVar.f0 = q.f1953b;
                h4 = h("connection", 1, 1);
                if (aVar.f0.length > 0) {
                }
                if (h4 != null) {
                }
                if (i("remote-random", 0, 0) != null) {
                }
                i19 = i("proto-force", 1, 1);
                if (i19 != null) {
                }
                String[] strArr2 = {"PROFILE", "FRIENDLY_NAME"};
                while (r8 < 2) {
                }
                vector = this.f29534h.get("USERNAME");
                if (vector != null) {
                }
                b(aVar);
                g(aVar);
                return aVar;
            }
            aVar.z0 = i35.get(1);
            if (!TextUtils.isEmpty(aVar.K) && !aVar.z0.contains(aVar.K)) {
                sb = new StringBuilder();
                sb.append(aVar.z0);
                str = ":";
                sb.append(str);
                sb.append(aVar.K);
                aVar.z0 = sb.toString();
            }
            i2 = i("auth", 1, 1);
            if (i2 != null) {
                aVar.U = i2.get(1);
            }
            i3 = i("ca", 1, 1);
            if (i3 != null) {
                aVar.f29507l = i3.get(1);
            }
            h2 = h("peer-fingerprint", 1, 1);
            if (h2 != null) {
                aVar.B0 = true;
                Iterator<Vector<String>> it5 = h2.iterator();
                while (it5.hasNext()) {
                    Vector<String> next4 = it5.next();
                    if (next4.get(1).startsWith("[[INLINE]]")) {
                        sb2 = new StringBuilder();
                        sb2.append(aVar.C0);
                        str2 = next4.get(1).substring(10);
                    } else {
                        sb2 = new StringBuilder();
                        sb2.append(aVar.C0);
                        str2 = next4.get(1);
                    }
                    sb2.append(str2);
                    sb2.append("\n");
                    aVar.C0 = sb2.toString();
                }
            }
            i4 = i("cert", 1, 1);
            if (i4 != null) {
                aVar.f29503h = i4.get(1);
                aVar.f29500e = 0;
                z = false;
            }
            i5 = i(TransferTable.COLUMN_KEY, 1, 1);
            if (i5 != null) {
                aVar.f29506k = i5.get(1);
            }
            i6 = i("pkcs12", 1, 1);
            if (i6 == null) {
                aVar.f29509n = i6.get(1);
                i7 = 2;
                aVar.f29500e = 2;
                z = false;
            } else {
                i7 = 2;
            }
            if (i("cryptoapicert", 1, 1) != null) {
                aVar.f29500e = i7;
                z = false;
            }
            Vector<String> i382 = i("compat-names", 1, i7);
            Vector<String> i392 = i("no-name-remapping", 1, 1);
            i8 = i("tls-remote", 1, 1);
            if (i8 == null) {
                aVar.B = i8.get(1);
                aVar.z = true;
                aVar.V = 0;
                if (i382 != null) {
                    i9 = 2;
                } else {
                    i9 = 2;
                }
            } else {
                i9 = 2;
            }
            i10 = i("verify-x509-name", 1, i9);
            if (i10 != null) {
                aVar.B = i10.get(1);
                aVar.z = true;
                if (i10.size() <= i9) {
                    i22 = 2;
                } else if (i10.get(i9).equals("name")) {
                    aVar.V = 3;
                } else if (i10.get(i9).equals("subject")) {
                    aVar.V = i9;
                } else if (!i10.get(i9).equals("name-prefix")) {
                    throw new a("Unknown parameter to verify-x509-name: " + i10.get(2));
                }
                aVar.V = i22;
            }
            i11 = i("x509-username-field", 1, 1);
            if (i11 != null) {
                aVar.W = i11.get(1);
            }
            i12 = i("verb", 1, 1);
            if (i12 != null) {
                aVar.J = i12.get(1);
            }
            if (i("nobind", 0, 0) != null) {
                aVar.L = true;
            }
            if (i("persist-tun", 0, 0) != null) {
                aVar.P = true;
            }
            if (i("push-peer-info", 0, 0) != null) {
                aVar.p0 = true;
            }
            i13 = i("connect-retry", 1, 2);
            if (i13 != null) {
                aVar.R = i13.get(1);
                if (i13.size() > 2) {
                    aVar.S = i13.get(2);
                }
            }
            i14 = i("connect-retry-max", 1, 1);
            if (i14 != null) {
                aVar.Q = i14.get(1);
            }
            h3 = h("remote-cert-tls", 1, 1);
            if (h3 != null) {
                if (h3.get(0).get(1).equals("server")) {
                    aVar.A = true;
                } else {
                    this.f29533g.put("remotetls", h3);
                }
            }
            i15 = i("auth-user-pass", 0, 1);
            if (i15 != null) {
                if (z) {
                    aVar.f29500e = 3;
                } else {
                    int i40 = aVar.f29500e;
                    if (i40 == 0) {
                        aVar.f29500e = 5;
                    } else if (i40 == 2) {
                        aVar.f29500e = 7;
                    }
                }
                if (i15.size() > 1) {
                    if (!i15.get(1).startsWith("[[INLINE]]")) {
                        this.f29535i = i15.get(1);
                    }
                    aVar.D = null;
                    v(aVar, i15.get(1));
                }
            }
            i16 = i("auth-retry", 1, 1);
            if (i16 != null) {
                if (!i16.get(1).equals("none")) {
                    if (i16.get(1).equals("nointeract")) {
                        i17 = 2;
                    } else {
                        i17 = 2;
                        if (!i16.get(1).equals("interact")) {
                            throw new a("Unknown parameter to auth-retry: " + i16.get(2));
                        }
                    }
                    aVar.n0 = i17;
                    i18 = i("crl-verify", 1, i17);
                    if (i18 != null) {
                        if (i18.size() == 3 && i18.get(i17).equals("dir")) {
                            aVar.I += m(" ", i18) + "\n";
                        } else {
                            aVar.k0 = i18.get(1);
                        }
                    }
                    a.i.q.e<e, e[]> q2 = q(null);
                    aVar.f0 = q2.f1953b;
                    h4 = h("connection", 1, 1);
                    if (aVar.f0.length > 0 || h4 == null) {
                        if (h4 != null) {
                            aVar.f0 = new e[h4.size()];
                            Iterator<Vector<String>> it6 = h4.iterator();
                            int i41 = 0;
                            while (it6.hasNext()) {
                                e[] eVarArr2 = p(it6.next().get(1), q2.f1952a).f1953b;
                                if (eVarArr2.length != 1) {
                                    throw new a("A <connection> block must have exactly one remote");
                                }
                                aVar.f0[i41] = eVarArr2[0];
                                i41++;
                            }
                        }
                        if (i("remote-random", 0, 0) != null) {
                            aVar.g0 = true;
                        }
                        i19 = i("proto-force", 1, 1);
                        if (i19 != null) {
                            String str11 = i19.get(1);
                            if (str11.equals("udp")) {
                                z2 = true;
                            } else if (!str11.equals("tcp")) {
                                throw new a(String.format("Unknown protocol %s in proto-force", str11));
                            } else {
                                z2 = false;
                            }
                            for (e eVar : aVar.f0) {
                                if (eVar.f29538d == z2) {
                                    eVar.f29541g = false;
                                }
                            }
                        }
                        String[] strArr22 = {"PROFILE", "FRIENDLY_NAME"};
                        for (int i42 = 0; i42 < 2; i42++) {
                            Vector<String> vector2 = this.f29534h.get(strArr22[i42]);
                            if (vector2 != null && vector2.size() > 1) {
                                aVar.f29501f = vector2.get(1);
                            }
                        }
                        vector = this.f29534h.get("USERNAME");
                        if (vector != null && vector.size() > 1) {
                            aVar.D = vector.get(1);
                        }
                        b(aVar);
                        g(aVar);
                        return aVar;
                    }
                    throw new a("Using a <connection> block and --remote is not allowed.");
                }
                aVar.n0 = 0;
            }
            i17 = 2;
            i18 = i("crl-verify", 1, i17);
            if (i18 != null) {
            }
            a.i.q.e<e, e[]> q22 = q(null);
            aVar.f0 = q22.f1953b;
            h4 = h("connection", 1, 1);
            if (aVar.f0.length > 0) {
            }
            if (h4 != null) {
            }
            if (i("remote-random", 0, 0) != null) {
            }
            i19 = i("proto-force", 1, 1);
            if (i19 != null) {
            }
            String[] strArr222 = {"PROFILE", "FRIENDLY_NAME"};
            while (i42 < 2) {
            }
            vector = this.f29534h.get("USERNAME");
            if (vector != null) {
                aVar.D = vector.get(1);
            }
            b(aVar);
            g(aVar);
            return aVar;
        }
        throw new a("Invalid mode for --mode specified, need p2p");
    }

    public final void g(d.a.a.a aVar) {
        if (aVar.B.equals(aVar.s0)) {
            aVar.B = BuildConfig.FLAVOR;
        }
    }

    public final Vector<Vector<String>> h(String str, int i2, int i3) {
        Vector<Vector<String>> vector = this.f29533g.get(str);
        if (vector == null) {
            return null;
        }
        Iterator<Vector<String>> it = vector.iterator();
        while (it.hasNext()) {
            Vector<String> next = it.next();
            if (next.size() < i2 + 1 || next.size() > i3 + 1) {
                throw new a(String.format(Locale.getDefault(), "Option %s has %d parameters, expected between %d and %d", str, Integer.valueOf(next.size() - 1), Integer.valueOf(i2), Integer.valueOf(i3)));
            }
            while (it.hasNext()) {
            }
        }
        this.f29533g.remove(str);
        return vector;
    }

    public final Vector<String> i(String str, int i2, int i3) {
        Vector<Vector<String>> h2 = h(str, i2, i3);
        if (h2 == null) {
            return null;
        }
        return h2.lastElement();
    }

    public final String j(Vector<Vector<String>> vector) {
        Iterator<String> it;
        Iterator<Vector<String>> it2 = vector.iterator();
        String str = BuildConfig.FLAVOR;
        while (it2.hasNext()) {
            Vector<String> next = it2.next();
            if (!k(next)) {
                if (next.size() == 2 && "extra-certs".equals(next.get(0))) {
                    str = str + d.a.a.a.H(next.get(0), next.get(1));
                } else {
                    while (next.iterator().hasNext()) {
                        str = str + d.a.a.a.M(it.next()) + " ";
                    }
                    str = str + "\n";
                }
            }
        }
        return str;
    }

    public boolean k(Vector<String> vector) {
        String[][] strArr;
        for (String[] strArr2 : this.f29530d) {
            if (vector.size() >= strArr2.length) {
                boolean z = true;
                for (int i2 = 0; i2 < strArr2.length; i2++) {
                    if (!strArr2[i2].equals(vector.get(i2))) {
                        z = false;
                    }
                }
                if (z) {
                    return true;
                }
            }
        }
        return false;
    }

    public final boolean l(String str) {
        if (str.equals("udp") || str.equals("udp4") || str.equals("udp6")) {
            return true;
        }
        if (str.equals("tcp-client") || str.equals("tcp") || str.equals("tcp4") || str.endsWith("tcp4-client") || str.equals("tcp6") || str.endsWith("tcp6-client")) {
            return false;
        }
        throw new a("Unsupported option to --proto " + str);
    }

    public final String m(String str, Vector<String> vector) {
        return Build.VERSION.SDK_INT > 26 ? d.a(str, vector) : TextUtils.join(str, vector);
    }

    public void n(Reader reader) {
        HashMap hashMap = new HashMap();
        hashMap.put("server-poll-timeout", "timeout-connect");
        BufferedReader bufferedReader = new BufferedReader(reader);
        int i2 = 0;
        while (true) {
            try {
                String readLine = bufferedReader.readLine();
                i2++;
                if (readLine == null) {
                    return;
                }
                if (i2 == 1) {
                    if (readLine.startsWith("PK\u0003\u0004") || readLine.startsWith("PK\u0007\u00008")) {
                        break;
                    } else if (readLine.startsWith("\ufeff")) {
                        readLine = readLine.substring(1);
                    }
                }
                if (readLine.startsWith("# OVPN_ACCESS_SERVER_")) {
                    Vector<String> s = s(readLine);
                    this.f29534h.put(s.get(0), s);
                } else {
                    Vector<String> r = r(readLine);
                    if (r.size() != 0) {
                        if (r.get(0).startsWith("--")) {
                            r.set(0, r.get(0).substring(2));
                        }
                        d(r, bufferedReader);
                        String str = r.get(0);
                        if (hashMap.get(str) != null) {
                            str = (String) hashMap.get(str);
                        }
                        if (!this.f29533g.containsKey(str)) {
                            this.f29533g.put(str, new Vector<>());
                        }
                        this.f29533g.get(str).add(r);
                    }
                }
            } catch (OutOfMemoryError e2) {
                throw new a("File too large to parse: " + e2.getLocalizedMessage());
            }
        }
        throw new a("Input looks like a ZIP Archive. Import is only possible for OpenVPN config files (.ovpn/.conf)");
    }

    public void o(Reader reader, String str, String str2, Context context) {
        this.f29527a = context;
        HashMap hashMap = new HashMap();
        hashMap.put("server-poll-timeout", "timeout-connect");
        BufferedReader bufferedReader = new BufferedReader(reader);
        int i2 = 0;
        while (true) {
            try {
                String readLine = bufferedReader.readLine();
                i2++;
                if (readLine == null) {
                    return;
                }
                if (i2 == 1) {
                    if (readLine.startsWith("PK\u0003\u0004") || readLine.startsWith("PK\u0007\u00008")) {
                        break;
                    } else if (readLine.startsWith("\ufeff")) {
                        readLine = readLine.substring(1);
                    }
                }
                if (readLine.startsWith("# OVPN_ACCESS_SERVER_")) {
                    Vector<String> s = s(readLine);
                    this.f29534h.put(s.get(0), s);
                } else {
                    Vector<String> r = r(readLine);
                    if (r.size() != 0) {
                        if (r.get(0).startsWith("--")) {
                            r.set(0, r.get(0).substring(2));
                        }
                        e(r, bufferedReader, str, str2);
                        String str3 = r.get(0);
                        if (hashMap.get(str3) != null) {
                            str3 = (String) hashMap.get(str3);
                        }
                        if (!this.f29533g.containsKey(str3)) {
                            this.f29533g.put(str3, new Vector<>());
                        }
                        this.f29533g.get(str3).add(r);
                    }
                }
            } catch (OutOfMemoryError e2) {
                throw new a("File too large to parse: " + e2.getLocalizedMessage());
            }
        }
        throw new a("Input looks like a ZIP Archive. Import is only possible for OpenVPN config files (.ovpn/.conf)");
    }

    public final a.i.q.e<e, e[]> p(String str, e eVar) {
        c cVar = new c();
        cVar.n(new StringReader(str.substring(10)));
        return cVar.q(eVar);
    }

    public final a.i.q.e<e, e[]> q(e eVar) {
        e clone;
        if (eVar != null) {
            try {
                clone = eVar.clone();
            } catch (CloneNotSupportedException e2) {
                e2.printStackTrace();
                return null;
            }
        } else {
            clone = new e();
        }
        Vector<String> i2 = i(IjkMediaPlayer.OnNativeInvokeListener.ARG_PORT, 1, 1);
        if (i2 != null) {
            clone.f29537c = i2.get(1);
        }
        Vector<String> i3 = i("rport", 1, 1);
        if (i3 != null) {
            clone.f29537c = i3.get(1);
        }
        Vector<String> i4 = i("proto", 1, 1);
        if (i4 != null) {
            clone.f29538d = l(i4.get(1));
        }
        Vector<String> i5 = i("connect-timeout", 1, 1);
        int i6 = 0;
        if (i5 != null) {
            try {
                clone.f29542h = Integer.parseInt(i5.get(1));
            } catch (NumberFormatException e3) {
                throw new a(String.format("Argument to connect-timeout (%s) must to be an integer: %s", i5.get(1), e3.getLocalizedMessage()));
            }
        }
        Vector<String> i7 = i("socks-proxy", 1, 2);
        if (i7 == null) {
            i7 = i("http-proxy", 2, 2);
        }
        if (i7 != null) {
            if (i7.get(0).equals("socks-proxy")) {
                clone.f29543i = e.a.SOCKS5;
                clone.f29545k = "1080";
            } else {
                clone.f29543i = e.a.HTTP;
            }
            clone.f29544j = i7.get(1);
            if (i7.size() >= 3) {
                clone.f29545k = i7.get(2);
            }
        }
        Vector<String> i8 = i("http-proxy-user-pass", 1, 1);
        if (i8 != null) {
            u(clone, i8.get(1));
        }
        Vector<Vector<String>> h2 = h("remote", 1, 3);
        Vector vector = new Vector();
        for (Map.Entry<String, Vector<Vector<String>>> entry : this.f29533g.entrySet()) {
            if (eVar != null || this.f29532f.contains(entry.getKey())) {
                clone.f29539e += j(entry.getValue());
                vector.add(entry.getKey());
            }
        }
        Iterator it = vector.iterator();
        while (it.hasNext()) {
            this.f29533g.remove((String) it.next());
        }
        String str = clone.f29539e;
        if (str != null && !BuildConfig.FLAVOR.equals(str.trim())) {
            clone.f29540f = true;
        }
        if (h2 == null) {
            h2 = new Vector<>();
        }
        e[] eVarArr = new e[h2.size()];
        Iterator<Vector<String>> it2 = h2.iterator();
        while (it2.hasNext()) {
            Vector<String> next = it2.next();
            try {
                eVarArr[i6] = clone.clone();
            } catch (CloneNotSupportedException e4) {
                e4.printStackTrace();
            }
            int size = next.size();
            if (size != 2) {
                if (size != 3) {
                    if (size != 4) {
                        i6++;
                    } else {
                        eVarArr[i6].f29538d = l(next.get(3));
                    }
                }
                eVarArr[i6].f29537c = next.get(2);
            }
            eVarArr[i6].f29536b = next.get(1);
            i6++;
        }
        return a.i.q.e.a(clone, eVarArr);
    }

    public final Vector<String> r(String str) {
        Vector<String> vector = new Vector<>();
        if (str.length() == 0) {
            return vector;
        }
        b bVar = b.initial;
        String str2 = BuildConfig.FLAVOR;
        int i2 = 0;
        boolean z = false;
        char c2 = 0;
        while (true) {
            char charAt = i2 < str.length() ? str.charAt(i2) : (char) 0;
            if (z || charAt != '\\' || bVar == b.readin_single_quote) {
                b bVar2 = b.initial;
                if (bVar == bVar2) {
                    if (!t(charAt)) {
                        if (charAt == ';' || charAt == '#') {
                            break;
                        } else if (!z && charAt == '\"') {
                            bVar = b.reading_quoted;
                        } else if (z || charAt != '\'') {
                            bVar = b.reading_unquoted;
                            c2 = charAt;
                        } else {
                            bVar = b.readin_single_quote;
                        }
                    }
                    if (bVar != b.done) {
                        vector.add(str2);
                        str2 = BuildConfig.FLAVOR;
                        c2 = 0;
                    } else {
                        bVar2 = bVar;
                    }
                    if (!z && c2 != 0 && c2 != '\\' && c2 != '\"' && !t(c2)) {
                        throw new a("Options warning: Bad backslash ('\\') usage");
                    }
                    bVar = bVar2;
                    z = false;
                } else {
                    if (bVar == b.reading_unquoted) {
                        if (!z) {
                        }
                        c2 = charAt;
                    } else if (bVar == b.reading_quoted) {
                        if (!z) {
                        }
                        c2 = charAt;
                    } else if (bVar == b.readin_single_quote) {
                    }
                    if (bVar != b.done) {
                    }
                    if (!z) {
                    }
                    bVar = bVar2;
                    z = false;
                }
            } else {
                z = true;
            }
            if (c2 != 0) {
                str2 = str2 + c2;
            }
            int i3 = i2 + 1;
            if (i2 >= str.length()) {
                break;
            }
            i2 = i3;
        }
        return vector;
    }

    public final Vector<String> s(String str) {
        String[] split = str.split("#\\sOVPN_ACCESS_SERVER_", 2)[1].split("=", 2);
        Vector<String> vector = new Vector<>();
        Collections.addAll(vector, split);
        return vector;
    }

    public final boolean t(char c2) {
        return Character.isWhitespace(c2) || c2 == 0;
    }
}