导航菜单

页面标题

页面副标题

Mint v5.7.3 - f.java 源代码

正在查看: Mint v5.7.3 应用的 f.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package hi;

import com.google.firebase.perf.FirebasePerformance;
import java.io.IOException;
import java.lang.ref.Reference;
import java.net.ConnectException;
import java.net.Proxy;
import java.net.Socket;
import java.net.SocketException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import ki.f;
import kotlin.Metadata;
import kotlin.collections.t;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.m;
import oh.o;
import oh.v;
import okhttp3.Address;
import okhttp3.Call;
import okhttp3.CertificatePinner;
import okhttp3.CipherSuite;
import okhttp3.Connection;
import okhttp3.ConnectionSpec;
import okhttp3.EventListener;
import okhttp3.Handshake;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import qi.d;
import si.b0;
import si.n;

@Metadata(d1 = {"\u0000è\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0014\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\n\u0018\u0000 ?2\u00020\u00012\u00020\u0002:\u0001GB\u0019\u0012\u0006\u0010Y\u001a\u00020T\u0012\u0006\u0010:\u001a\u00020\u001b¢\u0006\u0006\b\u0086\u0001\u0010\u0087\u0001J0\u0010\f\u001a\u00020\u000b2\u0006\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0002J(\u0010\r\u001a\u00020\u000b2\u0006\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0002J(\u0010\u0011\u001a\u00020\u000b2\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0010\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0002J\u0010\u0010\u0012\u001a\u00020\u000b2\u0006\u0010\u0010\u001a\u00020\u0003H\u0002J\u0010\u0010\u0013\u001a\u00020\u000b2\u0006\u0010\u000f\u001a\u00020\u000eH\u0002J*\u0010\u0018\u001a\u0004\u0018\u00010\u00142\u0006\u0010\u0005\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u00032\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0017\u001a\u00020\u0016H\u0002J\b\u0010\u0019\u001a\u00020\u0014H\u0002J\u0016\u0010\u001e\u001a\u00020\u001d2\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\u001b0\u001aH\u0002J\u0010\u0010\u001f\u001a\u00020\u001d2\u0006\u0010\u0017\u001a\u00020\u0016H\u0002J\u0018\u0010\"\u001a\u00020\u001d2\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010!\u001a\u00020 H\u0002J\u000f\u0010#\u001a\u00020\u000bH\u0000¢\u0006\u0004\b#\u0010$J\u000f\u0010%\u001a\u00020\u000bH\u0000¢\u0006\u0004\b%\u0010$J\u000f\u0010&\u001a\u00020\u000bH\u0000¢\u0006\u0004\b&\u0010$J>\u0010(\u001a\u00020\u000b2\u0006\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u00032\u0006\u0010'\u001a\u00020\u001d2\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tJ'\u0010,\u001a\u00020\u001d2\u0006\u0010*\u001a\u00020)2\u000e\u0010+\u001a\n\u0012\u0004\u0012\u00020\u001b\u0018\u00010\u001aH\u0000¢\u0006\u0004\b,\u0010-J\u001f\u00103\u001a\u0002022\u0006\u0010/\u001a\u00020.2\u0006\u00101\u001a\u000200H\u0000¢\u0006\u0004\b3\u00104J\u0017\u00108\u001a\u0002072\u0006\u00106\u001a\u000205H\u0000¢\u0006\u0004\b8\u00109J\b\u0010:\u001a\u00020\u001bH\u0016J\u0006\u0010;\u001a\u00020\u000bJ\b\u0010=\u001a\u00020<H\u0016J\u000e\u0010?\u001a\u00020\u001d2\u0006\u0010>\u001a\u00020\u001dJ\u0010\u0010B\u001a\u00020\u000b2\u0006\u0010A\u001a\u00020@H\u0016J\u0018\u0010G\u001a\u00020\u000b2\u0006\u0010D\u001a\u00020C2\u0006\u0010F\u001a\u00020EH\u0016J\n\u0010!\u001a\u0004\u0018\u00010 H\u0016J'\u0010K\u001a\u00020\u000b2\u0006\u0010/\u001a\u00020.2\u0006\u0010H\u001a\u00020\u001b2\u0006\u0010J\u001a\u00020IH\u0000¢\u0006\u0004\bK\u0010LJ!\u0010N\u001a\u00020\u000b2\u0006\u0010\b\u001a\u00020M2\b\u0010\"\u001a\u0004\u0018\u00010IH\u0000¢\u0006\u0004\bN\u0010OJ\b\u0010Q\u001a\u00020PH\u0016J\b\u0010S\u001a\u00020RH\u0016R\u0017\u0010Y\u001a\u00020T8\u0006¢\u0006\f\n\u0004\bU\u0010V\u001a\u0004\bW\u0010XR\u0014\u0010:\u001a\u00020\u001b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b;\u0010ZR\u0018\u0010\\\u001a\u0004\u0018\u00010<8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\"\u0010[R\u0018\u0010=\u001a\u0004\u0018\u00010<8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b(\u0010[R\u0018\u0010!\u001a\u0004\u0018\u00010 8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bK\u0010]R\u0018\u0010Q\u001a\u0004\u0018\u00010P8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\r\u0010^R\u0018\u0010`\u001a\u0004\u0018\u00010C8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0013\u0010_R\u0018\u0010c\u001a\u0004\u0018\u00010a8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\f\u0010bR\u0018\u0010f\u001a\u0004\u0018\u00010d8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0018\u0010eR\"\u0010l\u001a\u00020\u001d8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\u0019\u0010g\u001a\u0004\bh\u0010i\"\u0004\bj\u0010kR\u0016\u0010m\u001a\u00020\u001d8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0011\u0010gR\"\u0010t\u001a\u00020\u00038\u0000@\u0000X\u0080\u000e¢\u0006\u0012\n\u0004\bn\u0010o\u001a\u0004\bp\u0010q\"\u0004\br\u0010sR\u0016\u0010v\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bu\u0010oR\u0016\u0010w\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bh\u0010oR\u0016\u0010x\u001a\u00020\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bp\u0010oR#\u0010}\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020M0z0y8\u0006¢\u0006\f\n\u0004\b&\u0010{\u001a\u0004\bn\u0010|R&\u0010\u0083\u0001\u001a\u00020~8\u0000@\u0000X\u0080\u000e¢\u0006\u0015\n\u0004\b,\u0010\u007f\u001a\u0005\bu\u0010\u0080\u0001\"\u0006\b\u0081\u0001\u0010\u0082\u0001R\u0016\u0010\u0085\u0001\u001a\u00020\u001d8@X\u0080\u0004¢\u0006\u0007\u001a\u0005\b\u0084\u0001\u0010i¨\u0006\u0088\u0001"}, d2 = {"Lhi/f;", "Lki/f$c;", "Lokhttp3/Connection;", "", "connectTimeout", "readTimeout", "writeTimeout", "Lokhttp3/Call;", "call", "Lokhttp3/EventListener;", "eventListener", "Lug/a0;", "j", "h", "Lhi/b;", "connectionSpecSelector", "pingIntervalMillis", "m", "C", "i", "Lokhttp3/Request;", "tunnelRequest", "Lokhttp3/HttpUrl;", "url", "k", "l", "", "Lokhttp3/Route;", "candidates", "", "z", "D", "Lokhttp3/Handshake;", "handshake", "e", "y", "()V", "x", "r", "connectionRetryEnabled", "f", "Lokhttp3/Address;", "address", "routes", "s", "(Lokhttp3/Address;Ljava/util/List;)Z", "Lokhttp3/OkHttpClient;", "client", "Lii/g;", "chain", "Lii/d;", "v", "(Lokhttp3/OkHttpClient;Lii/g;)Lii/d;", "Lhi/c;", "exchange", "Lqi/d$d;", "w", "(Lhi/c;)Lqi/d$d;", "route", "d", "Ljava/net/Socket;", "socket", "doExtensiveChecks", "t", "Lki/i;", "stream", "b", "Lki/f;", "connection", "Lki/m;", "settings", "a", "failedRoute", "Ljava/io/IOException;", "failure", "g", "(Lokhttp3/OkHttpClient;Lokhttp3/Route;Ljava/io/IOException;)V", "Lhi/e;", "E", "(Lhi/e;Ljava/io/IOException;)V", "Lokhttp3/Protocol;", "protocol", "", "toString", "Lhi/g;", "c", "Lhi/g;", "getConnectionPool", "()Lhi/g;", "connectionPool", "Lokhttp3/Route;", "Ljava/net/Socket;", "rawSocket", "Lokhttp3/Handshake;", "Lokhttp3/Protocol;", "Lki/f;", "http2Connection", "Lsi/e;", "Lsi/e;", "source", "Lsi/d;", "Lsi/d;", "sink", "Z", "p", "()Z", "B", "(Z)V", "noNewExchanges", "noCoalescedConnections", "n", "I", "q", "()I", "setRouteFailureCount$okhttp", "(I)V", "routeFailureCount", "o", "successCount", "refusedStreamCount", "allocationLimit", "", "Ljava/lang/ref/Reference;", "Ljava/util/List;", "()Ljava/util/List;", "calls", "", "J", "()J", "A", "(J)V", "idleAtNs", "u", "isMultiplexed", "<init>", "(Lhi/g;Lokhttp3/Route;)V", "okhttp"}, k = 1, mv = {1, 6, 0})
public final class f extends f.c implements Connection {

    private final g connectionPool;

    private final Route route;

    private Socket rawSocket;

    private Socket socket;

    private Handshake handshake;

    private Protocol protocol;

    private ki.f http2Connection;

    private si.e source;

    private si.d sink;

    private boolean noNewExchanges;

    private boolean noCoalescedConnections;

    private int routeFailureCount;

    private int successCount;

    private int refusedStreamCount;

    private int allocationLimit;

    private final List<Reference<hi.e>> calls;

    private long idleAtNs;

    @Metadata(k = 3, mv = {1, 6, 0}, xi = 48)
    public class b {
        public static final int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[Proxy.Type.values().length];
            iArr[Proxy.Type.DIRECT.ordinal()] = 1;
            iArr[Proxy.Type.HTTP.ordinal()] = 2;
            $EnumSwitchMapping$0 = iArr;
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\b\u0012\u0004\u0012\u00020\u00020\u0001H\n¢\u0006\u0002\b\u0003"}, d2 = {"<anonymous>", "", "Ljava/security/cert/Certificate;", "invoke"}, k = 3, mv = {1, 6, 0}, xi = 48)
    static final class c extends Lambda implements fh.a<List<? extends Certificate>> {
        final CertificatePinner a;
        final Handshake b;
        final Address c;

        c(CertificatePinner certificatePinner, Handshake handshake, Address address) {
            super(0);
            this.a = certificatePinner;
            this.b = handshake;
            this.c = address;
        }

        @Override
        public final List<? extends Certificate> invoke() {
            pi.c certificateChainCleaner = this.a.getCertificateChainCleaner();
            m.d(certificateChainCleaner);
            return certificateChainCleaner.a(this.b.peerCertificates(), this.c.url().host());
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\b\u0012\u0004\u0012\u00020\u00020\u0001H\n¢\u0006\u0002\b\u0003"}, d2 = {"<anonymous>", "", "Ljava/security/cert/X509Certificate;", "invoke"}, k = 3, mv = {1, 6, 0}, xi = 48)
    static final class d extends Lambda implements fh.a<List<? extends X509Certificate>> {
        d() {
            super(0);
        }

        @Override
        public final List<? extends X509Certificate> invoke() {
            Handshake handshake = f.this.handshake;
            m.d(handshake);
            List<Certificate> peerCertificates = handshake.peerCertificates();
            ArrayList arrayList = new ArrayList(t.v(peerCertificates, 10));
            Iterator<T> it = peerCertificates.iterator();
            while (it.hasNext()) {
                arrayList.add((X509Certificate) ((Certificate) it.next()));
            }
            return arrayList;
        }
    }

    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u0004"}, d2 = {"hi/f$e", "Lqi/d$d;", "Lug/a0;", "close", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class e extends d.AbstractC0069d {
        final si.e d;
        final si.d e;
        final hi.c f;

        e(si.e eVar, si.d dVar, hi.c cVar) {
            super(true, eVar, dVar);
            this.d = eVar;
            this.e = dVar;
            this.f = cVar;
        }

        @Override
        public void close() {
            this.f.a(-1L, true, true, null);
        }
    }

    public f(g connectionPool, Route route) {
        m.g(connectionPool, "connectionPool");
        m.g(route, "route");
        this.connectionPool = connectionPool;
        this.route = route;
        this.allocationLimit = 1;
        this.calls = new ArrayList();
        this.idleAtNs = Long.MAX_VALUE;
    }

    private final void C(int i) throws IOException {
        Socket socket = this.socket;
        m.d(socket);
        si.e eVar = this.source;
        m.d(eVar);
        si.d dVar = this.sink;
        m.d(dVar);
        socket.setSoTimeout(0);
        ki.f a = new f.a(true, gi.e.i).s(socket, this.route.address().url().host(), eVar, dVar).k(this).l(i).a();
        this.http2Connection = a;
        this.allocationLimit = ki.f.INSTANCE.a().d();
        ki.f.Q0(a, false, null, 3, null);
    }

    private final boolean D(HttpUrl url) {
        Handshake handshake;
        if (di.e.h && !Thread.holdsLock(this)) {
            throw new AssertionError("Thread " + ((Object) Thread.currentThread().getName()) + " MUST hold lock on " + this);
        }
        HttpUrl url2 = this.route.address().url();
        if (url.port() != url2.port()) {
            return false;
        }
        if (m.b(url.host(), url2.host())) {
            return true;
        }
        if (this.noCoalescedConnections || (handshake = this.handshake) == null) {
            return false;
        }
        m.d(handshake);
        return e(url, handshake);
    }

    private final boolean e(HttpUrl url, Handshake handshake) {
        List<Certificate> peerCertificates = handshake.peerCertificates();
        return (peerCertificates.isEmpty() ^ true) && pi.d.a.e(url.host(), (X509Certificate) peerCertificates.get(0));
    }

    private final void h(int i, int i2, Call call, EventListener eventListener) throws IOException {
        Socket createSocket;
        Proxy proxy = this.route.proxy();
        Address address = this.route.address();
        Proxy.Type type = proxy.type();
        int i3 = type == null ? -1 : b.$EnumSwitchMapping$0[type.ordinal()];
        if (i3 == 1 || i3 == 2) {
            createSocket = address.socketFactory().createSocket();
            m.d(createSocket);
        } else {
            createSocket = new Socket(proxy);
        }
        this.rawSocket = createSocket;
        eventListener.connectStart(call, this.route.socketAddress(), proxy);
        createSocket.setSoTimeout(i2);
        try {
            mi.j.INSTANCE.g().f(createSocket, this.route.socketAddress(), i);
            try {
                this.source = n.d(n.l(createSocket));
                this.sink = n.c(n.h(createSocket));
            } catch (NullPointerException e2) {
                if (m.b(e2.getMessage(), "throw with null exception")) {
                    throw new IOException(e2);
                }
            }
        } catch (ConnectException e3) {
            ConnectException connectException = new ConnectException(m.o("Failed to connect to ", this.route.socketAddress()));
            connectException.initCause(e3);
            throw connectException;
        }
    }

    private final void i(hi.b bVar) throws IOException {
        String h;
        Address address = this.route.address();
        SSLSocketFactory sslSocketFactory = address.sslSocketFactory();
        SSLSocket sSLSocket = null;
        try {
            m.d(sslSocketFactory);
            Socket createSocket = sslSocketFactory.createSocket(this.rawSocket, address.url().host(), address.url().port(), true);
            if (createSocket == null) {
                throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.SSLSocket");
            }
            SSLSocket sSLSocket2 = (SSLSocket) createSocket;
            try {
                ConnectionSpec a = bVar.a(sSLSocket2);
                if (a.supportsTlsExtensions()) {
                    mi.j.INSTANCE.g().e(sSLSocket2, address.url().host(), address.protocols());
                }
                sSLSocket2.startHandshake();
                SSLSession sslSocketSession = sSLSocket2.getSession();
                Handshake.Companion companion = Handshake.INSTANCE;
                m.f(sslSocketSession, "sslSocketSession");
                Handshake handshake = companion.get(sslSocketSession);
                HostnameVerifier hostnameVerifier = address.hostnameVerifier();
                m.d(hostnameVerifier);
                if (hostnameVerifier.verify(address.url().host(), sslSocketSession)) {
                    CertificatePinner certificatePinner = address.certificatePinner();
                    m.d(certificatePinner);
                    this.handshake = new Handshake(handshake.tlsVersion(), handshake.cipherSuite(), handshake.localCertificates(), new c(certificatePinner, handshake, address));
                    certificatePinner.check$okhttp(address.url().host(), new d());
                    String h2 = a.supportsTlsExtensions() ? mi.j.INSTANCE.g().h(sSLSocket2) : null;
                    this.socket = sSLSocket2;
                    this.source = n.d(n.l(sSLSocket2));
                    this.sink = n.c(n.h(sSLSocket2));
                    this.protocol = h2 != null ? Protocol.INSTANCE.get(h2) : Protocol.HTTP_1_1;
                    mi.j.INSTANCE.g().b(sSLSocket2);
                    return;
                }
                List<Certificate> peerCertificates = handshake.peerCertificates();
                if (!(!peerCertificates.isEmpty())) {
                    throw new SSLPeerUnverifiedException("Hostname " + address.url().host() + " not verified (no certificates)");
                }
                X509Certificate x509Certificate = (X509Certificate) peerCertificates.get(0);
                h = o.h("\n              |Hostname " + address.url().host() + " not verified:\n              |    certificate: " + CertificatePinner.INSTANCE.pin(x509Certificate) + "\n              |    DN: " + ((Object) x509Certificate.getSubjectDN().getName()) + "\n              |    subjectAltNames: " + pi.d.a.a(x509Certificate) + "\n              ", null, 1, null);
                throw new SSLPeerUnverifiedException(h);
            } catch (Throwable th2) {
                th = th2;
                sSLSocket = sSLSocket2;
                if (sSLSocket != null) {
                    mi.j.INSTANCE.g().b(sSLSocket);
                }
                if (sSLSocket != null) {
                    di.e.n(sSLSocket);
                }
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
        }
    }

    private final void j(int i, int i2, int i3, Call call, EventListener eventListener) throws IOException {
        Request l = l();
        HttpUrl url = l.url();
        int i7 = 0;
        while (i7 < 21) {
            i7++;
            h(i, i2, call, eventListener);
            l = k(i2, i3, l, url);
            if (l == null) {
                return;
            }
            Socket socket = this.rawSocket;
            if (socket != null) {
                di.e.n(socket);
            }
            this.rawSocket = null;
            this.sink = null;
            this.source = null;
            eventListener.connectEnd(call, this.route.socketAddress(), this.route.proxy(), null);
        }
    }

    private final Request k(int readTimeout, int writeTimeout, Request tunnelRequest, HttpUrl url) throws IOException {
        String str = "CONNECT " + di.e.U(url, true) + " HTTP/1.1";
        while (true) {
            si.e eVar = this.source;
            m.d(eVar);
            si.d dVar = this.sink;
            m.d(dVar);
            ji.b bVar = new ji.b(null, this, eVar, dVar);
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            eVar.getTimeout().g(readTimeout, timeUnit);
            dVar.getTimeout().g(writeTimeout, timeUnit);
            bVar.B(tunnelRequest.headers(), str);
            bVar.a();
            Response.Builder g = bVar.g(false);
            m.d(g);
            Response build = g.request(tunnelRequest).build();
            bVar.A(build);
            int code = build.code();
            if (code == 200) {
                if (eVar.getBufferField().U() && dVar.getBufferField().U()) {
                    return null;
                }
                throw new IOException("TLS tunnel buffered too many bytes!");
            }
            if (code != 407) {
                throw new IOException(m.o("Unexpected response code for CONNECT: ", Integer.valueOf(build.code())));
            }
            Request authenticate = this.route.address().proxyAuthenticator().authenticate(this.route, build);
            if (authenticate == null) {
                throw new IOException("Failed to authenticate with proxy");
            }
            if (v.t("close", Response.header$default(build, "Connection", null, 2, null), true)) {
                return authenticate;
            }
            tunnelRequest = authenticate;
        }
    }

    private final Request l() throws IOException {
        Request build = new Request.Builder().url(this.route.address().url()).method(FirebasePerformance.HttpMethod.CONNECT, null).header("Host", di.e.U(this.route.address().url(), true)).header("Proxy-Connection", "Keep-Alive").header("User-Agent", "okhttp/4.10.0").build();
        Request authenticate = this.route.address().proxyAuthenticator().authenticate(this.route, new Response.Builder().request(build).protocol(Protocol.HTTP_1_1).code(407).message("Preemptive Authenticate").body(di.e.c).sentRequestAtMillis(-1L).receivedResponseAtMillis(-1L).header("Proxy-Authenticate", "OkHttp-Preemptive").build());
        return authenticate == null ? build : authenticate;
    }

    private final void m(hi.b bVar, int i, Call call, EventListener eventListener) throws IOException {
        if (this.route.address().sslSocketFactory() != null) {
            eventListener.secureConnectStart(call);
            i(bVar);
            eventListener.secureConnectEnd(call, this.handshake);
            if (this.protocol == Protocol.HTTP_2) {
                C(i);
                return;
            }
            return;
        }
        List<Protocol> protocols = this.route.address().protocols();
        Protocol protocol = Protocol.H2_PRIOR_KNOWLEDGE;
        if (!protocols.contains(protocol)) {
            this.socket = this.rawSocket;
            this.protocol = Protocol.HTTP_1_1;
        } else {
            this.socket = this.rawSocket;
            this.protocol = protocol;
            C(i);
        }
    }

    private final boolean z(List<Route> candidates) {
        List<Route> list = candidates;
        if ((list instanceof Collection) && list.isEmpty()) {
            return false;
        }
        for (Route route : list) {
            if (route.proxy().type() == Proxy.Type.DIRECT && this.route.proxy().type() == Proxy.Type.DIRECT && m.b(this.route.socketAddress(), route.socketAddress())) {
                return true;
            }
        }
        return false;
    }

    public final void A(long j) {
        this.idleAtNs = j;
    }

    public final void B(boolean z) {
        this.noNewExchanges = z;
    }

    public final synchronized void E(hi.e call, IOException e2) {
        m.g(call, "call");
        if (e2 instanceof ki.n) {
            if (((ki.n) e2).errorCode == ki.b.REFUSED_STREAM) {
                int i = this.refusedStreamCount + 1;
                this.refusedStreamCount = i;
                if (i > 1) {
                    this.noNewExchanges = true;
                    this.routeFailureCount++;
                }
            } else if (((ki.n) e2).errorCode != ki.b.CANCEL || !call.getCanceled()) {
                this.noNewExchanges = true;
                this.routeFailureCount++;
            }
        } else if (!u() || (e2 instanceof ki.a)) {
            this.noNewExchanges = true;
            if (this.successCount == 0) {
                if (e2 != null) {
                    g(call.getClient(), this.route, e2);
                }
                this.routeFailureCount++;
            }
        }
    }

    @Override
    public synchronized void a(ki.f connection, ki.m settings) {
        m.g(connection, "connection");
        m.g(settings, "settings");
        this.allocationLimit = settings.d();
    }

    @Override
    public void b(ki.i stream) throws IOException {
        m.g(stream, "stream");
        stream.d(ki.b.REFUSED_STREAM, null);
    }

    public final void d() {
        Socket socket = this.rawSocket;
        if (socket == null) {
            return;
        }
        di.e.n(socket);
    }

    public final void f(int r17, int r18, int r19, int r20, boolean r21, okhttp3.Call r22, okhttp3.EventListener r23) {
        throw new UnsupportedOperationException("Method not decompiled: hi.f.f(int, int, int, int, boolean, okhttp3.Call, okhttp3.EventListener):void");
    }

    public final void g(OkHttpClient client, Route failedRoute, IOException failure) {
        m.g(client, "client");
        m.g(failedRoute, "failedRoute");
        m.g(failure, "failure");
        if (failedRoute.proxy().type() != Proxy.Type.DIRECT) {
            Address address = failedRoute.address();
            address.proxySelector().connectFailed(address.url().uri(), failedRoute.proxy().address(), failure);
        }
        client.getRouteDatabase().b(failedRoute);
    }

    @Override
    public Handshake getHandshake() {
        return this.handshake;
    }

    public final List<Reference<hi.e>> n() {
        return this.calls;
    }

    public final long getIdleAtNs() {
        return this.idleAtNs;
    }

    public final boolean getNoNewExchanges() {
        return this.noNewExchanges;
    }

    @Override
    public Protocol protocol() {
        Protocol protocol = this.protocol;
        m.d(protocol);
        return protocol;
    }

    public final int getRouteFailureCount() {
        return this.routeFailureCount;
    }

    public final synchronized void r() {
        this.successCount++;
    }

    @Override
    public Route getRoute() {
        return this.route;
    }

    public final boolean s(Address address, List<Route> routes) {
        m.g(address, "address");
        if (di.e.h && !Thread.holdsLock(this)) {
            throw new AssertionError("Thread " + ((Object) Thread.currentThread().getName()) + " MUST hold lock on " + this);
        }
        if (this.calls.size() >= this.allocationLimit || this.noNewExchanges || !this.route.address().equalsNonHost$okhttp(address)) {
            return false;
        }
        if (m.b(address.url().host(), getRoute().address().url().host())) {
            return true;
        }
        if (this.http2Connection == null || routes == null || !z(routes) || address.hostnameVerifier() != pi.d.a || !D(address.url())) {
            return false;
        }
        try {
            CertificatePinner certificatePinner = address.certificatePinner();
            m.d(certificatePinner);
            String host = address.url().host();
            Handshake handshake = getHandshake();
            m.d(handshake);
            certificatePinner.check(host, handshake.peerCertificates());
            return true;
        } catch (SSLPeerUnverifiedException unused) {
            return false;
        }
    }

    @Override
    public Socket socket() {
        Socket socket = this.socket;
        m.d(socket);
        return socket;
    }

    public final boolean t(boolean doExtensiveChecks) {
        long idleAtNs;
        if (di.e.h && Thread.holdsLock(this)) {
            throw new AssertionError("Thread " + ((Object) Thread.currentThread().getName()) + " MUST NOT hold lock on " + this);
        }
        long nanoTime = System.nanoTime();
        Socket socket = this.rawSocket;
        m.d(socket);
        Socket socket2 = this.socket;
        m.d(socket2);
        si.e eVar = this.source;
        m.d(eVar);
        if (socket.isClosed() || socket2.isClosed() || socket2.isInputShutdown() || socket2.isOutputShutdown()) {
            return false;
        }
        ki.f fVar = this.http2Connection;
        if (fVar != null) {
            return fVar.B0(nanoTime);
        }
        synchronized (this) {
            idleAtNs = nanoTime - getIdleAtNs();
        }
        if (idleAtNs < 10000000000L || !doExtensiveChecks) {
            return true;
        }
        return di.e.G(socket2, eVar);
    }

    public String toString() {
        CipherSuite cipherSuite;
        StringBuilder sb = new StringBuilder();
        sb.append("Connection{");
        sb.append(this.route.address().url().host());
        sb.append(':');
        sb.append(this.route.address().url().port());
        sb.append(", proxy=");
        sb.append(this.route.proxy());
        sb.append(" hostAddress=");
        sb.append(this.route.socketAddress());
        sb.append(" cipherSuite=");
        Handshake handshake = this.handshake;
        Object obj = "none";
        if (handshake != null && (cipherSuite = handshake.cipherSuite()) != null) {
            obj = cipherSuite;
        }
        sb.append(obj);
        sb.append(" protocol=");
        sb.append(this.protocol);
        sb.append('}');
        return sb.toString();
    }

    public final boolean u() {
        return this.http2Connection != null;
    }

    public final ii.d v(OkHttpClient client, ii.g chain) throws SocketException {
        m.g(client, "client");
        m.g(chain, "chain");
        Socket socket = this.socket;
        m.d(socket);
        si.e eVar = this.source;
        m.d(eVar);
        si.d dVar = this.sink;
        m.d(dVar);
        ki.f fVar = this.http2Connection;
        if (fVar != null) {
            return new ki.g(client, this, chain, fVar);
        }
        socket.setSoTimeout(chain.readTimeoutMillis());
        b0 timeout = eVar.getTimeout();
        long readTimeoutMillis = chain.getReadTimeoutMillis();
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        timeout.g(readTimeoutMillis, timeUnit);
        dVar.getTimeout().g(chain.getWriteTimeoutMillis(), timeUnit);
        return new ji.b(client, this, eVar, dVar);
    }

    public final d.AbstractC0069d w(hi.c exchange) throws SocketException {
        m.g(exchange, "exchange");
        Socket socket = this.socket;
        m.d(socket);
        si.e eVar = this.source;
        m.d(eVar);
        si.d dVar = this.sink;
        m.d(dVar);
        socket.setSoTimeout(0);
        y();
        return new e(eVar, dVar, exchange);
    }

    public final synchronized void x() {
        this.noCoalescedConnections = true;
    }

    public final synchronized void y() {
        this.noNewExchanges = true;
    }
}