米游社.apk(点击下载) / e.java


package ek;

import com.mihoyo.commlib.utils.LogUtils;
import com.mihoyo.hotfix.runtime.patch.RuntimeDirector;
import com.xiaomi.mipush.sdk.Constants;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import sy.c0;
import sy.e0;
import sy.f;
import t4.h;

/* compiled from: TVCDnsCache */
public class e {

    /* renamed from: d  reason: collision with root package name */
    public static final String f57763d = "TVC-TVCDnsCache";

    /* renamed from: e  reason: collision with root package name */
    public static String f57764e = "https://119.29.29.99/d?dn=";

    /* renamed from: f  reason: collision with root package name */
    public static String f57765f = "800654663";
    public static RuntimeDirector m__m;

    /* renamed from: a  reason: collision with root package name */
    public OkHttpClient f57766a;

    /* renamed from: b  reason: collision with root package name */
    public ConcurrentHashMap<String, List<String>> f57767b = new ConcurrentHashMap<>();

    /* renamed from: c  reason: collision with root package name */
    public ConcurrentHashMap<String, List<String>> f57768c = new ConcurrentHashMap<>();

    /* compiled from: TVCDnsCache */
    public class a implements f {
        public static RuntimeDirector m__m;

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ f f57769a;

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ String f57770b;

        public a(f fVar, String str) {
            this.f57769a = fVar;
            this.f57770b = str;
        }

        @Override // sy.f
        public void onFailure(sy.e eVar, IOException iOException) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                f fVar = this.f57769a;
                if (fVar != null) {
                    fVar.onFailure(eVar, iOException);
                }
                LogUtils logUtils = LogUtils.INSTANCE;
                logUtils.w(e.f57763d, "freshDNS failed :" + iOException.getMessage());
                return;
            }
            runtimeDirector.invocationDispatch(0, this, eVar, iOException);
        }

        @Override // sy.f
        public void onResponse(sy.e eVar, e0 e0Var) throws IOException {
            String[] split;
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(1)) {
                if (e0Var != null && e0Var.k0()) {
                    String string = e0Var.E().string();
                    LogUtils.INSTANCE.i(e.f57763d, "freshDNS succ :" + string);
                    if (!(string == null || string.length() == 0)) {
                        ArrayList arrayList = new ArrayList();
                        if (string.contains(h.f134437b)) {
                            for (String str : string.split(h.f134437b)) {
                                arrayList.add(str);
                            }
                        } else {
                            arrayList.add(string);
                        }
                        e.this.f57767b.put(this.f57770b, arrayList);
                        f fVar = this.f57769a;
                        if (fVar != null) {
                            fVar.onResponse(eVar, e0Var);
                            return;
                        }
                    }
                }
                f fVar2 = this.f57769a;
                if (fVar2 != null) {
                    fVar2.onFailure(eVar, new IOException("freshDNS failed"));
                    return;
                }
                return;
            }
            runtimeDirector.invocationDispatch(1, this, eVar, e0Var);
        }
    }

    public e() {
        OkHttpClient.a newBuilder = new OkHttpClient().newBuilder();
        TimeUnit timeUnit = TimeUnit.SECONDS;
        this.f57766a = newBuilder.k(5, timeUnit).j0(5, timeUnit).R0(5, timeUnit).f();
    }

    public static boolean g() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(4)) {
            return ((Boolean) runtimeDirector.invocationDispatch(4, null, ga.a.f66507a)).booleanValue();
        }
        String property = System.getProperty("http.proxyHost");
        String property2 = System.getProperty("http.proxyPort");
        if (property == null || property2 == null) {
            return false;
        }
        LogUtils logUtils = LogUtils.INSTANCE;
        logUtils.i(f57763d, "use proxy " + property + Constants.COLON_SEPARATOR + property2 + ", will not use httpdns");
        return true;
    }

    public void b(String str, ArrayList<String> arrayList) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(1)) {
            runtimeDirector.invocationDispatch(1, this, str, arrayList);
        } else if (!g() && arrayList != null && arrayList.size() != 0) {
            this.f57768c.put(str, arrayList);
        }
    }

    public void c() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(5)) {
            this.f57767b.clear();
            this.f57768c.clear();
            return;
        }
        runtimeDirector.invocationDispatch(5, this, ga.a.f66507a);
    }

    public boolean d(String str, f fVar) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(0)) {
            return ((Boolean) runtimeDirector.invocationDispatch(0, this, str, fVar)).booleanValue();
        } else if (g()) {
            return false;
        } else {
            String str2 = f57764e + str + "&token=" + f57765f;
            LogUtils.INSTANCE.i(f57763d, "freshDNS->request url:" + str2);
            this.f57766a.newCall(new c0.a().B(str2).b()).G(new a(fVar, str));
            return true;
        }
    }

    public List<String> e(String str) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(2)) {
            List<String> list = this.f57767b.get(str);
            if (list != null && list.size() > 0) {
                return list;
            }
            List<String> list2 = this.f57768c.get(str);
            if (list2 == null || list2.size() <= 0) {
                return null;
            }
            return list2;
        }
        return (List) runtimeDirector.invocationDispatch(2, this, str);
    }

    public boolean f(String str) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(3)) {
            return ((Boolean) runtimeDirector.invocationDispatch(3, this, str)).booleanValue();
        } else if (!this.f57767b.containsKey(str) || this.f57767b.get(str).size() <= 0) {
            return this.f57768c.containsKey(str) && this.f57768c.get(str).size() > 0;
        } else {
            return true;
        }
    }
}