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

应用版本信息
应用名称:FreeTelec
版本号:1.13.0
包名称:fr.r0ro.android.FreeTelec

MD5 校验值:1c0b849068c6d731df1325f993a128f9

反编译源代码说明

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


package b5;

import e5.f;
import e5.n;
import java.io.IOException;
import java.lang.ref.Reference;
import java.net.ConnectException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownServiceException;
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 k5.c0;
import k5.p;
import l4.m;
import w4.a0;
import w4.b0;
import w4.d0;
import w4.f0;
import w4.l;
import w4.t;
import w4.u;
import w4.w;
import w4.z;

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

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

    private Socket f876c;

    private Socket f877d;

    private u f878e;

    private a0 f879f;

    private e5.f f880g;

    private k5.h f881h;

    private k5.g f882i;

    private boolean f883j;

    private boolean f884k;

    private int f885l;

    private int f886m;

    private int f887n;

    private int f888o;

    private final List<Reference<e>> f889p;

    private long f890q;

    private final h f891r;

    private final f0 f892s;

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

        public a(q4.d dVar) {
            this();
        }
    }

    public static final class b extends q4.g implements p4.a<List<? extends Certificate>> {

        final w4.g f893d;

        final u f894f;

        final w4.a f895g;

        b(w4.g gVar, u uVar, w4.a aVar) {
            super(0);
            this.f893d = gVar;
            this.f894f = uVar;
            this.f895g = aVar;
        }

        @Override
        public final List<Certificate> a() {
            j5.c d6 = this.f893d.d();
            q4.f.b(d6);
            return d6.a(this.f894f.d(), this.f895g.l().h());
        }
    }

    public static final class c extends q4.g implements p4.a<List<? extends X509Certificate>> {
        c() {
            super(0);
        }

        @Override
        public final List<X509Certificate> a() {
            int n6;
            u uVar = f.this.f878e;
            q4.f.b(uVar);
            List<Certificate> d6 = uVar.d();
            n6 = m.n(d6, 10);
            ArrayList arrayList = new ArrayList(n6);
            for (Certificate certificate : d6) {
                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, f0 f0Var) {
        q4.f.d(hVar, "connectionPool");
        q4.f.d(f0Var, "route");
        this.f891r = hVar;
        this.f892s = f0Var;
        this.f888o = 1;
        this.f889p = new ArrayList();
        this.f890q = Long.MAX_VALUE;
    }

    private final boolean A(List<f0> list) {
        if (!(list instanceof Collection) || !list.isEmpty()) {
            for (f0 f0Var : list) {
                if (f0Var.b().type() == Proxy.Type.DIRECT && this.f892s.b().type() == Proxy.Type.DIRECT && q4.f.a(this.f892s.d(), f0Var.d())) {
                    return true;
                }
            }
        }
        return false;
    }

    private final void E(int i6) throws IOException {
        Socket socket = this.f877d;
        q4.f.b(socket);
        k5.h hVar = this.f881h;
        q4.f.b(hVar);
        k5.g gVar = this.f882i;
        q4.f.b(gVar);
        socket.setSoTimeout(0);
        e5.f a6 = new f.b(true, a5.e.f172h).m(socket, this.f892s.a().l().h(), hVar, gVar).k(this).l(i6).a();
        this.f880g = a6;
        this.f888o = e5.f.M.a().d();
        e5.f.Z0(a6, false, null, 3, null);
    }

    private final boolean F(w wVar) {
        u uVar;
        if (x4.b.f22007h && !Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            q4.f.c(currentThread, "Thread.currentThread()");
            sb.append(currentThread.getName());
            sb.append(" MUST hold lock on ");
            sb.append(this);
            throw new AssertionError(sb.toString());
        }
        w l6 = this.f892s.a().l();
        if (wVar.l() != l6.l()) {
            return false;
        }
        if (q4.f.a(wVar.h(), l6.h())) {
            return true;
        }
        if (this.f884k || (uVar = this.f878e) == null) {
            return false;
        }
        q4.f.b(uVar);
        return e(wVar, uVar);
    }

    private final boolean e(w wVar, u uVar) {
        List<Certificate> d6 = uVar.d();
        if (!d6.isEmpty()) {
            j5.d dVar = j5.d.f19084a;
            String h6 = wVar.h();
            Certificate certificate = d6.get(0);
            Objects.requireNonNull(certificate, "null cannot be cast to non-null type java.security.cert.X509Certificate");
            if (dVar.e(h6, (X509Certificate) certificate)) {
                return true;
            }
        }
        return false;
    }

    private final void h(int i6, int i7, w4.e eVar, t tVar) throws IOException {
        Socket socket;
        int i8;
        Proxy b6 = this.f892s.b();
        w4.a a6 = this.f892s.a();
        Proxy.Type type = b6.type();
        if (type == null || ((i8 = g.f897a[type.ordinal()]) != 1 && i8 != 2)) {
            socket = new Socket(b6);
        } else {
            socket = a6.j().createSocket();
            q4.f.b(socket);
        }
        this.f876c = socket;
        tVar.j(eVar, this.f892s.d(), b6);
        socket.setSoTimeout(i7);
        try {
            g5.h.f18729c.g().f(socket, this.f892s.d(), i6);
            try {
                this.f881h = p.d(p.l(socket));
                this.f882i = p.c(p.h(socket));
            } catch (NullPointerException e6) {
                if (q4.f.a(e6.getMessage(), "throw with null exception")) {
                    throw new IOException(e6);
                }
            }
        } catch (ConnectException e7) {
            ConnectException connectException = new ConnectException("Failed to connect to " + this.f892s.d());
            connectException.initCause(e7);
            throw connectException;
        }
    }

    private final void i(b5.b bVar) throws IOException {
        String e6;
        w4.a a6 = this.f892s.a();
        SSLSocketFactory k6 = a6.k();
        SSLSocket sSLSocket = null;
        try {
            q4.f.b(k6);
            Socket createSocket = k6.createSocket(this.f876c, a6.l().h(), a6.l().l(), true);
            if (createSocket != null) {
                SSLSocket sSLSocket2 = (SSLSocket) createSocket;
                try {
                    l a7 = bVar.a(sSLSocket2);
                    if (a7.h()) {
                        g5.h.f18729c.g().e(sSLSocket2, a6.l().h(), a6.f());
                    }
                    sSLSocket2.startHandshake();
                    SSLSession session = sSLSocket2.getSession();
                    u.a aVar = u.f21770e;
                    q4.f.c(session, "sslSocketSession");
                    u a8 = aVar.a(session);
                    HostnameVerifier e7 = a6.e();
                    q4.f.b(e7);
                    if (!e7.verify(a6.l().h(), session)) {
                        List<Certificate> d6 = a8.d();
                        if (!d6.isEmpty()) {
                            Certificate certificate = d6.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(a6.l().h());
                            sb.append(" not verified:\n              |    certificate: ");
                            sb.append(w4.g.f21635d.a(x509Certificate));
                            sb.append("\n              |    DN: ");
                            Principal subjectDN = x509Certificate.getSubjectDN();
                            q4.f.c(subjectDN, "cert.subjectDN");
                            sb.append(subjectDN.getName());
                            sb.append("\n              |    subjectAltNames: ");
                            sb.append(j5.d.f19084a.a(x509Certificate));
                            sb.append("\n              ");
                            e6 = v4.i.e(sb.toString(), null, 1, null);
                            throw new SSLPeerUnverifiedException(e6);
                        }
                        throw new SSLPeerUnverifiedException("Hostname " + a6.l().h() + " not verified (no certificates)");
                    }
                    w4.g a9 = a6.a();
                    q4.f.b(a9);
                    this.f878e = new u(a8.e(), a8.a(), a8.c(), new b(a9, a8, a6));
                    a9.b(a6.l().h(), new c());
                    String h6 = a7.h() ? g5.h.f18729c.g().h(sSLSocket2) : null;
                    this.f877d = sSLSocket2;
                    this.f881h = p.d(p.l(sSLSocket2));
                    this.f882i = p.c(p.h(sSLSocket2));
                    this.f879f = h6 != null ? a0.f21523p.a(h6) : a0.HTTP_1_1;
                    g5.h.f18729c.g().b(sSLSocket2);
                    return;
                } catch (Throwable th) {
                    th = th;
                    sSLSocket = sSLSocket2;
                    if (sSLSocket != null) {
                        g5.h.f18729c.g().b(sSLSocket);
                    }
                    if (sSLSocket != null) {
                        x4.b.j(sSLSocket);
                    }
                    throw th;
                }
            }
            throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.SSLSocket");
        } catch (Throwable th2) {
            th = th2;
        }
    }

    private final void j(int i6, int i7, int i8, w4.e eVar, t tVar) throws IOException {
        b0 l6 = l();
        w j6 = l6.j();
        for (int i9 = 0; i9 < 21; i9++) {
            h(i6, i7, eVar, tVar);
            l6 = k(i7, i8, l6, j6);
            if (l6 == null) {
                return;
            }
            Socket socket = this.f876c;
            if (socket != null) {
                x4.b.j(socket);
            }
            this.f876c = null;
            this.f882i = null;
            this.f881h = null;
            tVar.h(eVar, this.f892s.d(), this.f892s.b(), null);
        }
    }

    private final b0 k(int i6, int i7, b0 b0Var, w wVar) throws IOException {
        boolean j6;
        String str = "CONNECT " + x4.b.L(wVar, true) + " HTTP/1.1";
        while (true) {
            k5.h hVar = this.f881h;
            q4.f.b(hVar);
            k5.g gVar = this.f882i;
            q4.f.b(gVar);
            d5.b bVar = new d5.b(null, this, hVar, gVar);
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            hVar.i().g(i6, timeUnit);
            gVar.i().g(i7, timeUnit);
            bVar.B(b0Var.f(), str);
            bVar.v();
            d0.a y5 = bVar.y(false);
            q4.f.b(y5);
            d0 c6 = y5.r(b0Var).c();
            bVar.r(c6);
            int e6 = c6.e();
            if (e6 == 200) {
                if (hVar.g().N() && gVar.g().N()) {
                    return null;
                }
                throw new IOException("TLS tunnel buffered too many bytes!");
            }
            if (e6 == 407) {
                b0 a6 = this.f892s.a().h().a(this.f892s, c6);
                if (a6 != null) {
                    j6 = v4.p.j("close", d0.B(c6, "Connection", null, 2, null), true);
                    if (j6) {
                        return a6;
                    }
                    b0Var = a6;
                } else {
                    throw new IOException("Failed to authenticate with proxy");
                }
            } else {
                throw new IOException("Unexpected response code for CONNECT: " + c6.e());
            }
        }
    }

    private final b0 l() throws IOException {
        b0 a6 = new b0.a().h(this.f892s.a().l()).e("CONNECT", null).c("Host", x4.b.L(this.f892s.a().l(), true)).c("Proxy-Connection", "Keep-Alive").c("User-Agent", "okhttp/4.9.3").a();
        b0 a7 = this.f892s.a().h().a(this.f892s, new d0.a().r(a6).p(a0.HTTP_1_1).g(407).m("Preemptive Authenticate").b(x4.b.f22002c).s(-1L).q(-1L).j("Proxy-Authenticate", "OkHttp-Preemptive").c());
        return a7 != null ? a7 : a6;
    }

    private final void m(b5.b bVar, int i6, w4.e eVar, t tVar) throws IOException {
        if (this.f892s.a().k() == null) {
            List<a0> f6 = this.f892s.a().f();
            a0 a0Var = a0.H2_PRIOR_KNOWLEDGE;
            if (f6.contains(a0Var)) {
                this.f877d = this.f876c;
                this.f879f = a0Var;
                E(i6);
                return;
            } else {
                this.f877d = this.f876c;
                this.f879f = a0.HTTP_1_1;
                return;
            }
        }
        tVar.C(eVar);
        i(bVar);
        tVar.B(eVar, this.f878e);
        if (this.f879f == a0.HTTP_2) {
            E(i6);
        }
    }

    public final void B(long j6) {
        this.f890q = j6;
    }

    public final void C(boolean z5) {
        this.f883j = z5;
    }

    public Socket D() {
        Socket socket = this.f877d;
        q4.f.b(socket);
        return socket;
    }

    public final synchronized void G(e eVar, IOException iOException) {
        q4.f.d(eVar, "call");
        if (iOException instanceof n) {
            if (((n) iOException).f18008c == e5.b.REFUSED_STREAM) {
                int i6 = this.f887n + 1;
                this.f887n = i6;
                if (i6 > 1) {
                    this.f883j = true;
                    this.f885l++;
                }
            } else if (((n) iOException).f18008c != e5.b.CANCEL || !eVar.u()) {
                this.f883j = true;
                this.f885l++;
            }
        } else if (!v() || (iOException instanceof e5.a)) {
            this.f883j = true;
            if (this.f886m == 0) {
                if (iOException != null) {
                    g(eVar.n(), this.f892s, iOException);
                }
                this.f885l++;
            }
        }
    }

    @Override
    public synchronized void a(e5.f fVar, e5.m mVar) {
        q4.f.d(fVar, "connection");
        q4.f.d(mVar, "settings");
        this.f888o = mVar.d();
    }

    @Override
    public void b(e5.i iVar) throws IOException {
        q4.f.d(iVar, "stream");
        iVar.d(e5.b.REFUSED_STREAM, null);
    }

    public final void d() {
        Socket socket = this.f876c;
        if (socket != null) {
            x4.b.j(socket);
        }
    }

    public final void f(int i6, int i7, int i8, int i9, boolean z5, w4.e eVar, t tVar) {
        Socket socket;
        Socket socket2;
        q4.f.d(eVar, "call");
        q4.f.d(tVar, "eventListener");
        if (this.f879f == null) {
            List<l> b6 = this.f892s.a().b();
            b5.b bVar = new b5.b(b6);
            if (this.f892s.a().k() == null) {
                if (b6.contains(l.f21732j)) {
                    String h6 = this.f892s.a().l().h();
                    if (!g5.h.f18729c.g().j(h6)) {
                        throw new j(new UnknownServiceException("CLEARTEXT communication to " + h6 + " not permitted by network security policy"));
                    }
                } else {
                    throw new j(new UnknownServiceException("CLEARTEXT communication not enabled for client"));
                }
            } else if (this.f892s.a().f().contains(a0.H2_PRIOR_KNOWLEDGE)) {
                throw new j(new UnknownServiceException("H2_PRIOR_KNOWLEDGE cannot be used with HTTPS"));
            }
            j jVar = null;
            do {
                try {
                    try {
                        if (this.f892s.c()) {
                            j(i6, i7, i8, eVar, tVar);
                            if (this.f876c == null) {
                                if (!this.f892s.c() && this.f876c == null) {
                                    throw new j(new ProtocolException("Too many tunnel connections attempted: 21"));
                                }
                                this.f890q = System.nanoTime();
                                return;
                            }
                        } else {
                            try {
                                h(i6, i7, eVar, tVar);
                            } catch (IOException e6) {
                                e = e6;
                                socket = this.f877d;
                                if (socket != null) {
                                }
                                socket2 = this.f876c;
                                if (socket2 != null) {
                                }
                                this.f877d = null;
                                this.f876c = null;
                                this.f881h = null;
                                this.f882i = null;
                                this.f878e = null;
                                this.f879f = null;
                                this.f880g = null;
                                this.f888o = 1;
                                tVar.i(eVar, this.f892s.d(), this.f892s.b(), null, e);
                                if (jVar != null) {
                                }
                                if (z5) {
                                }
                            }
                        }
                        m(bVar, i9, eVar, tVar);
                        tVar.h(eVar, this.f892s.d(), this.f892s.b(), this.f879f);
                        if (!this.f892s.c()) {
                        }
                        this.f890q = System.nanoTime();
                        return;
                    } catch (IOException e7) {
                        e = e7;
                        socket = this.f877d;
                        if (socket != null) {
                            x4.b.j(socket);
                        }
                        socket2 = this.f876c;
                        if (socket2 != null) {
                            x4.b.j(socket2);
                        }
                        this.f877d = null;
                        this.f876c = null;
                        this.f881h = null;
                        this.f882i = null;
                        this.f878e = null;
                        this.f879f = null;
                        this.f880g = null;
                        this.f888o = 1;
                        tVar.i(eVar, this.f892s.d(), this.f892s.b(), null, e);
                        if (jVar != null) {
                            jVar = new j(e);
                        } else {
                            jVar.a(e);
                        }
                        if (z5) {
                            throw jVar;
                        }
                    }
                } catch (IOException e8) {
                    e = e8;
                }
            } while (bVar.b(e));
            throw jVar;
        }
        throw new IllegalStateException("already connected".toString());
    }

    public final void g(z zVar, f0 f0Var, IOException iOException) {
        q4.f.d(zVar, "client");
        q4.f.d(f0Var, "failedRoute");
        q4.f.d(iOException, "failure");
        if (f0Var.b().type() != Proxy.Type.DIRECT) {
            w4.a a6 = f0Var.a();
            a6.i().connectFailed(a6.l().q(), f0Var.b().address(), iOException);
        }
        zVar.u().b(f0Var);
    }

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

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

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

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

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

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

    public final boolean t(w4.a aVar, List<f0> list) {
        q4.f.d(aVar, "address");
        if (x4.b.f22007h && !Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            q4.f.c(currentThread, "Thread.currentThread()");
            sb.append(currentThread.getName());
            sb.append(" MUST hold lock on ");
            sb.append(this);
            throw new AssertionError(sb.toString());
        }
        if (this.f889p.size() >= this.f888o || this.f883j || !this.f892s.a().d(aVar)) {
            return false;
        }
        if (q4.f.a(aVar.l().h(), z().a().l().h())) {
            return true;
        }
        if (this.f880g == null || list == null || !A(list) || aVar.e() != j5.d.f19084a || !F(aVar.l())) {
            return false;
        }
        try {
            w4.g a6 = aVar.a();
            q4.f.b(a6);
            String h6 = aVar.l().h();
            u r5 = r();
            q4.f.b(r5);
            a6.a(h6, r5.d());
            return true;
        } catch (SSLPeerUnverifiedException unused) {
            return false;
        }
    }

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

    public final boolean u(boolean z5) {
        long j6;
        if (x4.b.f22007h && Thread.holdsLock(this)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread currentThread = Thread.currentThread();
            q4.f.c(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.f876c;
        q4.f.b(socket);
        Socket socket2 = this.f877d;
        q4.f.b(socket2);
        k5.h hVar = this.f881h;
        q4.f.b(hVar);
        if (socket.isClosed() || socket2.isClosed() || socket2.isInputShutdown() || socket2.isOutputShutdown()) {
            return false;
        }
        e5.f fVar = this.f880g;
        if (fVar != null) {
            return fVar.L0(nanoTime);
        }
        synchronized (this) {
            j6 = nanoTime - this.f890q;
        }
        if (j6 < 10000000000L || !z5) {
            return true;
        }
        return x4.b.C(socket2, hVar);
    }

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

    public final c5.d w(z zVar, c5.g gVar) throws SocketException {
        q4.f.d(zVar, "client");
        q4.f.d(gVar, "chain");
        Socket socket = this.f877d;
        q4.f.b(socket);
        k5.h hVar = this.f881h;
        q4.f.b(hVar);
        k5.g gVar2 = this.f882i;
        q4.f.b(gVar2);
        e5.f fVar = this.f880g;
        if (fVar != null) {
            return new e5.g(zVar, this, gVar, fVar);
        }
        socket.setSoTimeout(gVar.k());
        c0 i6 = hVar.i();
        long h6 = gVar.h();
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        i6.g(h6, timeUnit);
        gVar2.i().g(gVar.j(), timeUnit);
        return new d5.b(zVar, this, hVar, gVar2);
    }

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

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

    public f0 z() {
        return this.f892s;
    }
}