导航菜单

页面标题

页面副标题

Top浏览器 v4.6.16 - f.java 源代码

正在查看: Top浏览器 v4.6.16 应用的 f.java JAVA 源代码文件

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


package k.i0.f;

import h.b0.d.l;
import h.b0.d.m;
import java.io.IOException;
import java.lang.ref.Reference;
import java.net.ConnectException;
import java.net.Proxy;
import java.net.Socket;
import java.security.Principal;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
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 k.a0;
import k.b0;
import k.c0;
import k.e0;
import k.g0;
import k.i0.i.f;
import k.i0.i.n;
import k.s;
import k.u;
import k.w;
import l.d0;
import l.q;
import org.adblockplus.libadblockplus.HttpClient;

public final class f extends f.d implements k.j {

    public static final a f3822c = new a(null);

    public Socket f3823d;

    public Socket f3824e;

    public u f3825f;

    public b0 f3826g;

    public k.i0.i.f f3827h;

    public l.g f3828i;

    public l.f f3829j;

    public boolean f3830k;

    public boolean f3831l;

    public int f3832m;
    public int n;
    public int o;
    public int p;
    public final List<Reference<e>> q;
    public long r;
    public final h s;
    public final g0 t;

    public static final class a {
        public a() {
        }

        public a(h.b0.d.g gVar) {
            this();
        }
    }

    public static final class b extends m implements h.b0.c.a<List<? extends Certificate>> {
        public final k.g a;
        public final u b;

        public final k.a f3833c;

        public b(k.g gVar, u uVar, k.a aVar) {
            super(0);
            this.a = gVar;
            this.b = uVar;
            this.f3833c = aVar;
        }

        @Override
        public final List<? extends Certificate> invoke() {
            k.i0.l.c d2 = this.a.d();
            l.d(d2);
            return d2.a(this.b.d(), this.f3833c.l().i());
        }
    }

    public static final class c extends m implements h.b0.c.a<List<? extends X509Certificate>> {
        public c() {
            super(0);
        }

        @Override
        public final List<? extends X509Certificate> invoke() {
            u uVar = f.this.f3825f;
            l.d(uVar);
            List<Certificate> d2 = uVar.d();
            ArrayList arrayList = new ArrayList(h.w.l.q(d2, 10));
            for (Certificate certificate : d2) {
                Objects.requireNonNull(certificate, "null cannot be cast to non-null type java.security.cert.X509Certificate");
                arrayList.add((X509Certificate) certificate);
            }
            return arrayList;
        }
    }

    public f(h hVar, g0 g0Var) {
        l.f(hVar, "connectionPool");
        l.f(g0Var, "route");
        this.s = hVar;
        this.t = g0Var;
        this.p = 1;
        this.q = new ArrayList();
        this.r = Long.MAX_VALUE;
    }

    public final boolean A(List<g0> list) {
        if (!(list instanceof Collection) || !list.isEmpty()) {
            for (g0 g0Var : list) {
                if (g0Var.b().type() == Proxy.Type.DIRECT && this.t.b().type() == Proxy.Type.DIRECT && l.b(this.t.d(), g0Var.d())) {
                    return true;
                }
            }
        }
        return false;
    }

    public final void B(long j2) {
        this.r = j2;
    }

    public final void C(boolean z) {
        this.f3830k = z;
    }

    public Socket D() {
        Socket socket = this.f3824e;
        l.d(socket);
        return socket;
    }

    public final void E(int i2) {
        Socket socket = this.f3824e;
        l.d(socket);
        l.g gVar = this.f3828i;
        l.d(gVar);
        l.f fVar = this.f3829j;
        l.d(fVar);
        socket.setSoTimeout(0);
        k.i0.i.f a2 = new f.b(true, k.i0.e.e.a).m(socket, this.t.a().l().i(), gVar, fVar).k(this).l(i2).a();
        this.f3827h = a2;
        this.p = k.i0.i.f.b.a().d();
        k.i0.i.f.s0(a2, false, null, 3, null);
    }

    public final boolean F(w wVar) {
        u uVar;
        if (k.i0.b.f3756h && !Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            l.e(currentThread, "Thread.currentThread()");
            sb.append(currentThread.getName());
            sb.append(" MUST hold lock on ");
            sb.append(this);
            throw new AssertionError(sb.toString());
        }
        w l2 = this.t.a().l();
        if (wVar.o() != l2.o()) {
            return false;
        }
        if (l.b(wVar.i(), l2.i())) {
            return true;
        }
        if (this.f3831l || (uVar = this.f3825f) == null) {
            return false;
        }
        l.d(uVar);
        return e(wVar, uVar);
    }

    public final synchronized void G(e eVar, IOException iOException) {
        l.f(eVar, "call");
        if (iOException instanceof n) {
            if (((n) iOException).a == k.i0.i.b.REFUSED_STREAM) {
                int i2 = this.o + 1;
                this.o = i2;
                if (i2 > 1) {
                    this.f3830k = true;
                    this.f3832m++;
                }
            } else if (((n) iOException).a != k.i0.i.b.CANCEL || !eVar.S()) {
                this.f3830k = true;
                this.f3832m++;
            }
        } else if (!v() || (iOException instanceof k.i0.i.a)) {
            this.f3830k = true;
            if (this.n == 0) {
                if (iOException != null) {
                    g(eVar.k(), this.t, iOException);
                }
                this.f3832m++;
            }
        }
    }

    @Override
    public synchronized void a(k.i0.i.f fVar, k.i0.i.m mVar) {
        l.f(fVar, "connection");
        l.f(mVar, "settings");
        this.p = mVar.d();
    }

    @Override
    public void b(k.i0.i.i iVar) {
        l.f(iVar, "stream");
        iVar.d(k.i0.i.b.REFUSED_STREAM, null);
    }

    public final void d() {
        Socket socket = this.f3823d;
        if (socket != null) {
            k.i0.b.k(socket);
        }
    }

    public final boolean e(w wVar, u uVar) {
        List<Certificate> d2 = uVar.d();
        if (!d2.isEmpty()) {
            k.i0.l.d dVar = k.i0.l.d.a;
            String i2 = wVar.i();
            Certificate certificate = d2.get(0);
            Objects.requireNonNull(certificate, "null cannot be cast to non-null type java.security.cert.X509Certificate");
            if (dVar.e(i2, (X509Certificate) certificate)) {
                return true;
            }
        }
        return false;
    }

    public final void f(int r17, int r18, int r19, int r20, boolean r21, k.e r22, k.s r23) {
        throw new UnsupportedOperationException("Method not decompiled: k.i0.f.f.f(int, int, int, int, boolean, k.e, k.s):void");
    }

    public final void g(a0 a0Var, g0 g0Var, IOException iOException) {
        l.f(a0Var, "client");
        l.f(g0Var, "failedRoute");
        l.f(iOException, "failure");
        if (g0Var.b().type() != Proxy.Type.DIRECT) {
            k.a a2 = g0Var.a();
            a2.i().connectFailed(a2.l().t(), g0Var.b().address(), iOException);
        }
        a0Var.t().b(g0Var);
    }

    public final void h(int i2, int i3, k.e eVar, s sVar) {
        Socket socket;
        int i4;
        Proxy b2 = this.t.b();
        k.a a2 = this.t.a();
        Proxy.Type type = b2.type();
        if (type != null && ((i4 = g.a[type.ordinal()]) == 1 || i4 == 2)) {
            socket = a2.j().createSocket();
            l.d(socket);
        } else {
            socket = new Socket(b2);
        }
        this.f3823d = socket;
        sVar.j(eVar, this.t.d(), b2);
        socket.setSoTimeout(i3);
        try {
            k.i0.j.h.f4069c.g().f(socket, this.t.d(), i2);
            try {
                this.f3828i = q.b(q.k(socket));
                this.f3829j = q.a(q.g(socket));
            } catch (NullPointerException e2) {
                if (l.b(e2.getMessage(), "throw with null exception")) {
                    throw new IOException(e2);
                }
            }
        } catch (ConnectException e3) {
            ConnectException connectException = new ConnectException("Failed to connect to " + this.t.d());
            connectException.initCause(e3);
            throw connectException;
        }
    }

    public final void i(k.i0.f.b bVar) {
        k.a a2 = this.t.a();
        SSLSocketFactory k2 = a2.k();
        SSLSocket sSLSocket = null;
        try {
            l.d(k2);
            Socket createSocket = k2.createSocket(this.f3823d, a2.l().i(), a2.l().o(), true);
            if (createSocket == null) {
                throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.SSLSocket");
            }
            SSLSocket sSLSocket2 = (SSLSocket) createSocket;
            try {
                k.l a3 = bVar.a(sSLSocket2);
                if (a3.h()) {
                    k.i0.j.h.f4069c.g().e(sSLSocket2, a2.l().i(), a2.f());
                }
                sSLSocket2.startHandshake();
                SSLSession session = sSLSocket2.getSession();
                u.a aVar = u.a;
                l.e(session, "sslSocketSession");
                u a4 = aVar.a(session);
                HostnameVerifier e2 = a2.e();
                l.d(e2);
                if (e2.verify(a2.l().i(), session)) {
                    k.g a5 = a2.a();
                    l.d(a5);
                    this.f3825f = new u(a4.e(), a4.a(), a4.c(), new b(a5, a4, a2));
                    a5.b(a2.l().i(), new c());
                    String g2 = a3.h() ? k.i0.j.h.f4069c.g().g(sSLSocket2) : null;
                    this.f3824e = sSLSocket2;
                    this.f3828i = q.b(q.k(sSLSocket2));
                    this.f3829j = q.a(q.g(sSLSocket2));
                    this.f3826g = g2 != null ? b0.f3677h.a(g2) : b0.HTTP_1_1;
                    k.i0.j.h.f4069c.g().b(sSLSocket2);
                    return;
                }
                List<Certificate> d2 = a4.d();
                if (!(!d2.isEmpty())) {
                    throw new SSLPeerUnverifiedException("Hostname " + a2.l().i() + " not verified (no certificates)");
                }
                Certificate certificate = d2.get(0);
                if (certificate == null) {
                    throw new NullPointerException("null cannot be cast to non-null type java.security.cert.X509Certificate");
                }
                X509Certificate x509Certificate = (X509Certificate) certificate;
                StringBuilder sb = new StringBuilder();
                sb.append("\n              |Hostname ");
                sb.append(a2.l().i());
                sb.append(" not verified:\n              |    certificate: ");
                sb.append(k.g.b.a(x509Certificate));
                sb.append("\n              |    DN: ");
                Principal subjectDN = x509Certificate.getSubjectDN();
                l.e(subjectDN, "cert.subjectDN");
                sb.append(subjectDN.getName());
                sb.append("\n              |    subjectAltNames: ");
                sb.append(k.i0.l.d.a.a(x509Certificate));
                sb.append("\n              ");
                throw new SSLPeerUnverifiedException(h.i0.l.i(sb.toString(), null, 1, null));
            } catch (Throwable th) {
                th = th;
                sSLSocket = sSLSocket2;
                if (sSLSocket != null) {
                    k.i0.j.h.f4069c.g().b(sSLSocket);
                }
                if (sSLSocket != null) {
                    k.i0.b.k(sSLSocket);
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void j(int i2, int i3, int i4, k.e eVar, s sVar) {
        c0 l2 = l();
        w j2 = l2.j();
        for (int i5 = 0; i5 < 21; i5++) {
            h(i2, i3, eVar, sVar);
            l2 = k(i3, i4, l2, j2);
            if (l2 == null) {
                return;
            }
            Socket socket = this.f3823d;
            if (socket != null) {
                k.i0.b.k(socket);
            }
            this.f3823d = null;
            this.f3829j = null;
            this.f3828i = null;
            sVar.h(eVar, this.t.d(), this.t.b(), null);
        }
    }

    public final c0 k(int i2, int i3, c0 c0Var, w wVar) {
        String str = "CONNECT " + k.i0.b.M(wVar, true) + " HTTP/1.1";
        while (true) {
            l.g gVar = this.f3828i;
            l.d(gVar);
            l.f fVar = this.f3829j;
            l.d(fVar);
            k.i0.h.b bVar = new k.i0.h.b(null, this, gVar, fVar);
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            gVar.timeout().g(i2, timeUnit);
            fVar.timeout().g(i3, timeUnit);
            bVar.A(c0Var.e(), str);
            bVar.c();
            e0.a f2 = bVar.f(false);
            l.d(f2);
            e0 c2 = f2.r(c0Var).c();
            bVar.z(c2);
            int l2 = c2.l();
            if (l2 == 200) {
                if (gVar.getBuffer().k() && fVar.getBuffer().k()) {
                    return null;
                }
                throw new IOException("TLS tunnel buffered too many bytes!");
            }
            if (l2 != 407) {
                throw new IOException("Unexpected response code for CONNECT: " + c2.l());
            }
            c0 authenticate = this.t.a().h().authenticate(this.t, c2);
            if (authenticate == null) {
                throw new IOException("Failed to authenticate with proxy");
            }
            if (h.i0.s.q("close", e0.v(c2, "Connection", null, 2, null), true)) {
                return authenticate;
            }
            c0Var = authenticate;
        }
    }

    public final c0 l() {
        c0 b2 = new c0.a().p(this.t.a().l()).j("CONNECT", null).h("Host", k.i0.b.M(this.t.a().l(), true)).h("Proxy-Connection", "Keep-Alive").h(HttpClient.HEADER_USER_AGENT, "okhttp/4.9.3").b();
        c0 authenticate = this.t.a().h().authenticate(this.t, new e0.a().r(b2).p(b0.HTTP_1_1).g(407).m("Preemptive Authenticate").b(k.i0.b.f3751c).s(-1L).q(-1L).j("Proxy-Authenticate", "OkHttp-Preemptive").c());
        return authenticate != null ? authenticate : b2;
    }

    public final void m(k.i0.f.b bVar, int i2, k.e eVar, s sVar) {
        if (this.t.a().k() != null) {
            sVar.C(eVar);
            i(bVar);
            sVar.B(eVar, this.f3825f);
            if (this.f3826g == b0.HTTP_2) {
                E(i2);
                return;
            }
            return;
        }
        List<b0> f2 = this.t.a().f();
        b0 b0Var = b0.H2_PRIOR_KNOWLEDGE;
        if (!f2.contains(b0Var)) {
            this.f3824e = this.f3823d;
            this.f3826g = b0.HTTP_1_1;
        } else {
            this.f3824e = this.f3823d;
            this.f3826g = b0Var;
            E(i2);
        }
    }

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

    public final long o() {
        return this.r;
    }

    public final boolean p() {
        return this.f3830k;
    }

    public final int q() {
        return this.f3832m;
    }

    public u r() {
        return this.f3825f;
    }

    public final synchronized void s() {
        this.n++;
    }

    public final boolean t(k.a aVar, List<g0> list) {
        l.f(aVar, "address");
        if (k.i0.b.f3756h && !Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            l.e(currentThread, "Thread.currentThread()");
            sb.append(currentThread.getName());
            sb.append(" MUST hold lock on ");
            sb.append(this);
            throw new AssertionError(sb.toString());
        }
        if (this.q.size() >= this.p || this.f3830k || !this.t.a().d(aVar)) {
            return false;
        }
        if (l.b(aVar.l().i(), z().a().l().i())) {
            return true;
        }
        if (this.f3827h == null || list == null || !A(list) || aVar.e() != k.i0.l.d.a || !F(aVar.l())) {
            return false;
        }
        try {
            k.g a2 = aVar.a();
            l.d(a2);
            String i2 = aVar.l().i();
            u r = r();
            l.d(r);
            a2.a(i2, r.d());
            return true;
        } catch (SSLPeerUnverifiedException unused) {
            return false;
        }
    }

    public String toString() {
        Object obj;
        StringBuilder sb = new StringBuilder();
        sb.append("Connection{");
        sb.append(this.t.a().l().i());
        sb.append(':');
        sb.append(this.t.a().l().o());
        sb.append(',');
        sb.append(" proxy=");
        sb.append(this.t.b());
        sb.append(" hostAddress=");
        sb.append(this.t.d());
        sb.append(" cipherSuite=");
        u uVar = this.f3825f;
        if (uVar == null || (obj = uVar.a()) == null) {
            obj = "none";
        }
        sb.append(obj);
        sb.append(" protocol=");
        sb.append(this.f3826g);
        sb.append('}');
        return sb.toString();
    }

    public final boolean u(boolean z) {
        long j2;
        if (k.i0.b.f3756h && Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            l.e(currentThread, "Thread.currentThread()");
            sb.append(currentThread.getName());
            sb.append(" MUST NOT hold lock on ");
            sb.append(this);
            throw new AssertionError(sb.toString());
        }
        long nanoTime = System.nanoTime();
        Socket socket = this.f3823d;
        l.d(socket);
        Socket socket2 = this.f3824e;
        l.d(socket2);
        l.g gVar = this.f3828i;
        l.d(gVar);
        if (socket.isClosed() || socket2.isClosed() || socket2.isInputShutdown() || socket2.isOutputShutdown()) {
            return false;
        }
        k.i0.i.f fVar = this.f3827h;
        if (fVar != null) {
            return fVar.e0(nanoTime);
        }
        synchronized (this) {
            j2 = nanoTime - this.r;
        }
        if (j2 < 10000000000L || !z) {
            return true;
        }
        return k.i0.b.C(socket2, gVar);
    }

    public final boolean v() {
        return this.f3827h != null;
    }

    public final k.i0.g.d w(a0 a0Var, k.i0.g.g gVar) {
        l.f(a0Var, "client");
        l.f(gVar, "chain");
        Socket socket = this.f3824e;
        l.d(socket);
        l.g gVar2 = this.f3828i;
        l.d(gVar2);
        l.f fVar = this.f3829j;
        l.d(fVar);
        k.i0.i.f fVar2 = this.f3827h;
        if (fVar2 != null) {
            return new k.i0.i.g(a0Var, this, gVar, fVar2);
        }
        socket.setSoTimeout(gVar.j());
        d0 timeout = gVar2.timeout();
        long g2 = gVar.g();
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        timeout.g(g2, timeUnit);
        fVar.timeout().g(gVar.i(), timeUnit);
        return new k.i0.h.b(a0Var, this, gVar2, fVar);
    }

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

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

    public g0 z() {
        return this.t;
    }
}