MD5 校验值:328357c6f846d37b47ed4cc8f5415f3d
f.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package l.k0.h; 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.SocketTimeoutException; import java.net.UnknownServiceException; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import l.b0; import l.c0; import l.e0; import l.g0; import l.i0; import l.k0.k.f; import l.n; import l.p; import l.v; import l.w; import l.y; import l.z; import m.l; import m.u; public final class f extends f.j implements n { public final g f8191b; private final i0 f8192c; private Socket f8193d; private Socket f8194e; private w f8195f; private c0 f8196g; private l.k0.k.f f8197h; private m.e f8198i; private m.d f8199j; boolean f8200k; int f8201l; int f8202m; private int n; private int o = 1; final List<Reference<k>> p = new ArrayList(); long q = Long.MAX_VALUE; public f(g gVar, i0 i0Var) { this.f8191b = gVar; this.f8192c = i0Var; } private void e(int i2, int i3, l.j jVar, v vVar) { Proxy b2 = this.f8192c.b(); this.f8193d = (b2.type() == Proxy.Type.DIRECT || b2.type() == Proxy.Type.HTTP) ? this.f8192c.a().j().createSocket() : new Socket(b2); vVar.f(jVar, this.f8192c.d(), b2); this.f8193d.setSoTimeout(i3); try { l.k0.l.f.l().h(this.f8193d, this.f8192c.d(), i2); try { this.f8198i = l.b(l.h(this.f8193d)); this.f8199j = l.a(l.e(this.f8193d)); } catch (NullPointerException e2) { if ("throw with null exception".equals(e2.getMessage())) { throw new IOException(e2); } } } catch (ConnectException e3) { ConnectException connectException = new ConnectException("Failed to connect to " + this.f8192c.d()); connectException.initCause(e3); throw connectException; } } private void f(c cVar) { SSLSocket sSLSocket; l.e a = this.f8192c.a(); SSLSocket sSLSocket2 = null; try { try { sSLSocket = (SSLSocket) a.k().createSocket(this.f8193d, a.l().l(), a.l().w(), true); } catch (AssertionError e2) { e = e2; } } catch (Throwable th) { th = th; } try { p a2 = cVar.a(sSLSocket); if (a2.f()) { l.k0.l.f.l().g(sSLSocket, a.l().l(), a.f()); } sSLSocket.startHandshake(); SSLSession session = sSLSocket.getSession(); w b2 = w.b(session); if (a.e().verify(a.l().l(), session)) { a.a().a(a.l().l(), b2.d()); String n = a2.f() ? l.k0.l.f.l().n(sSLSocket) : null; this.f8194e = sSLSocket; this.f8198i = l.b(l.h(sSLSocket)); this.f8199j = l.a(l.e(this.f8194e)); this.f8195f = b2; this.f8196g = n != null ? c0.d(n) : c0.HTTP_1_1; l.k0.l.f.l().a(sSLSocket); return; } List<Certificate> d2 = b2.d(); if (d2.isEmpty()) { throw new SSLPeerUnverifiedException("Hostname " + a.l().l() + " not verified (no certificates)"); } X509Certificate x509Certificate = (X509Certificate) d2.get(0); throw new SSLPeerUnverifiedException("Hostname " + a.l().l() + " not verified:\n certificate: " + l.l.c(x509Certificate) + "\n DN: " + x509Certificate.getSubjectDN().getName() + "\n subjectAltNames: " + l.k0.n.d.a(x509Certificate)); } catch (AssertionError e3) { e = e3; if (!l.k0.e.y(e)) { throw e; } throw new IOException(e); } catch (Throwable th2) { th = th2; sSLSocket2 = sSLSocket; if (sSLSocket2 != null) { l.k0.l.f.l().a(sSLSocket2); } l.k0.e.f(sSLSocket2); throw th; } } private void g(int i2, int i3, int i4, l.j jVar, v vVar) { e0 i5 = i(); y h2 = i5.h(); for (int i6 = 0; i6 < 21; i6++) { e(i2, i3, jVar, vVar); i5 = h(i3, i4, i5, h2); if (i5 == null) { return; } l.k0.e.f(this.f8193d); this.f8193d = null; this.f8199j = null; this.f8198i = null; vVar.d(jVar, this.f8192c.d(), this.f8192c.b(), null); } } private e0 h(int i2, int i3, e0 e0Var, y yVar) { String str = "CONNECT " + l.k0.e.q(yVar, true) + " HTTP/1.1"; l.k0.j.a aVar = new l.k0.j.a(null, null, this.f8198i, this.f8199j); u o = this.f8198i.o(); long j2 = i2; TimeUnit timeUnit = TimeUnit.MILLISECONDS; o.g(j2, timeUnit); this.f8199j.o().g(i3, timeUnit); aVar.B(e0Var.d(), str); aVar.a(); g0 c2 = aVar.g(false).q(e0Var).c(); aVar.A(c2); int c3 = c2.c(); if (c3 == 200) { if (this.f8198i.Q().S() && this.f8199j.d().S()) { return null; } throw new IOException("TLS tunnel buffered too many bytes!"); } if (c3 == 407) { this.f8192c.a().h().a(this.f8192c, c2); throw new IOException("Failed to authenticate with proxy"); } throw new IOException("Unexpected response code for CONNECT: " + c2.c()); } private e0 i() { e0 a = new e0.a().h(this.f8192c.a().l()).e("CONNECT", null).c("Host", l.k0.e.q(this.f8192c.a().l(), true)).c("Proxy-Connection", "Keep-Alive").c("User-Agent", l.k0.f.a()).a(); this.f8192c.a().h().a(this.f8192c, new g0.a().q(a).o(c0.HTTP_1_1).g(407).l("Preemptive Authenticate").b(l.k0.e.f8153d).r(-1L).p(-1L).i("Proxy-Authenticate", "OkHttp-Preemptive").c()); return a; } private void j(c cVar, int i2, l.j jVar, v vVar) { if (this.f8192c.a().k() != null) { vVar.x(jVar); f(cVar); vVar.w(jVar, this.f8195f); if (this.f8196g == c0.HTTP_2) { t(i2); return; } return; } List<c0> f2 = this.f8192c.a().f(); c0 c0Var = c0.H2_PRIOR_KNOWLEDGE; if (!f2.contains(c0Var)) { this.f8194e = this.f8193d; this.f8196g = c0.HTTP_1_1; } else { this.f8194e = this.f8193d; this.f8196g = c0Var; t(i2); } } private boolean r(List<i0> list) { int size = list.size(); for (int i2 = 0; i2 < size; i2++) { i0 i0Var = list.get(i2); if (i0Var.b().type() == Proxy.Type.DIRECT && this.f8192c.b().type() == Proxy.Type.DIRECT && this.f8192c.d().equals(i0Var.d())) { return true; } } return false; } private void t(int i2) { this.f8194e.setSoTimeout(0); l.k0.k.f a = new f.h(true).d(this.f8194e, this.f8192c.a().l().l(), this.f8198i, this.f8199j).b(this).c(i2).a(); this.f8197h = a; a.R(); } @Override public void a(l.k0.k.f fVar) { synchronized (this.f8191b) { this.o = fVar.v(); } } @Override public void b(l.k0.k.i iVar) { iVar.d(l.k0.k.b.REFUSED_STREAM, null); } public void c() { l.k0.e.f(this.f8193d); } public void d(int i2, int i3, int i4, int i5, boolean z, l.j jVar, v vVar) { if (this.f8196g != null) { throw new IllegalStateException("already connected"); } List<p> b2 = this.f8192c.a().b(); c cVar = new c(b2); if (this.f8192c.a().k() == null) { if (!b2.contains(p.f8352f)) { throw new i(new UnknownServiceException("CLEARTEXT communication not enabled for client")); } String l2 = this.f8192c.a().l().l(); if (!l.k0.l.f.l().q(l2)) { throw new i(new UnknownServiceException("CLEARTEXT communication to " + l2 + " not permitted by network security policy")); } } else if (this.f8192c.a().f().contains(c0.H2_PRIOR_KNOWLEDGE)) { throw new i(new UnknownServiceException("H2_PRIOR_KNOWLEDGE cannot be used with HTTPS")); } i iVar = null; do { try { } catch (IOException e2) { e = e2; } try { if (this.f8192c.c()) { g(i2, i3, i4, jVar, vVar); if (this.f8193d == null) { if (!this.f8192c.c() && this.f8193d == null) { throw new i(new ProtocolException("Too many tunnel connections attempted: 21")); } if (this.f8197h == null) { synchronized (this.f8191b) { this.o = this.f8197h.v(); } return; } return; } } else { try { e(i2, i3, jVar, vVar); } catch (IOException e3) { e = e3; l.k0.e.f(this.f8194e); l.k0.e.f(this.f8193d); this.f8194e = null; this.f8193d = null; this.f8198i = null; this.f8199j = null; this.f8195f = null; this.f8196g = null; this.f8197h = null; vVar.e(jVar, this.f8192c.d(), this.f8192c.b(), null, e); if (iVar != null) { iVar = new i(e); } else { iVar.a(e); } if (z) { throw iVar; } } } j(cVar, i5, jVar, vVar); vVar.d(jVar, this.f8192c.d(), this.f8192c.b(), this.f8196g); if (!this.f8192c.c()) { } if (this.f8197h == null) { } } catch (IOException e4) { e = e4; l.k0.e.f(this.f8194e); l.k0.e.f(this.f8193d); this.f8194e = null; this.f8193d = null; this.f8198i = null; this.f8199j = null; this.f8195f = null; this.f8196g = null; this.f8197h = null; vVar.e(jVar, this.f8192c.d(), this.f8192c.b(), null, e); if (iVar != null) { } if (z) { } } } while (cVar.b(e)); throw iVar; } public w k() { return this.f8195f; } public boolean l(l.e eVar, List<i0> list) { if (this.p.size() >= this.o || this.f8200k || !l.k0.c.a.e(this.f8192c.a(), eVar)) { return false; } if (eVar.l().l().equals(q().a().l().l())) { return true; } if (this.f8197h == null || list == null || !r(list) || eVar.e() != l.k0.n.d.a || !u(eVar.l())) { return false; } try { eVar.a().a(eVar.l().l(), k().d()); return true; } catch (SSLPeerUnverifiedException unused) { return false; } } public boolean m(boolean z) { if (this.f8194e.isClosed() || this.f8194e.isInputShutdown() || this.f8194e.isOutputShutdown()) { return false; } l.k0.k.f fVar = this.f8197h; if (fVar != null) { return fVar.t(System.nanoTime()); } if (z) { try { int soTimeout = this.f8194e.getSoTimeout(); try { this.f8194e.setSoTimeout(1); return !this.f8198i.S(); } finally { this.f8194e.setSoTimeout(soTimeout); } } catch (SocketTimeoutException unused) { } catch (IOException unused2) { return false; } } return true; } public boolean n() { return this.f8197h != null; } public l.k0.i.c o(b0 b0Var, z.a aVar) { if (this.f8197h != null) { return new l.k0.k.g(b0Var, this, aVar, this.f8197h); } this.f8194e.setSoTimeout(aVar.b()); u o = this.f8198i.o(); long b2 = aVar.b(); TimeUnit timeUnit = TimeUnit.MILLISECONDS; o.g(b2, timeUnit); this.f8199j.o().g(aVar.c(), timeUnit); return new l.k0.j.a(b0Var, this, this.f8198i, this.f8199j); } public void p() { synchronized (this.f8191b) { this.f8200k = true; } } public i0 q() { return this.f8192c; } public Socket s() { return this.f8194e; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Connection{"); sb.append(this.f8192c.a().l().l()); sb.append(":"); sb.append(this.f8192c.a().l().w()); sb.append(", proxy="); sb.append(this.f8192c.b()); sb.append(" hostAddress="); sb.append(this.f8192c.d()); sb.append(" cipherSuite="); w wVar = this.f8195f; sb.append(wVar != null ? wVar.a() : "none"); sb.append(" protocol="); sb.append(this.f8196g); sb.append('}'); return sb.toString(); } public boolean u(y yVar) { if (yVar.w() != this.f8192c.a().l().w()) { return false; } if (yVar.l().equals(this.f8192c.a().l().l())) { return true; } return this.f8195f != null && l.k0.n.d.a.c(yVar.l(), (X509Certificate) this.f8195f.d().get(0)); } public void v(IOException iOException) { int i2; synchronized (this.f8191b) { if (iOException instanceof l.k0.k.n) { l.k0.k.b bVar = ((l.k0.k.n) iOException).p; if (bVar == l.k0.k.b.REFUSED_STREAM) { int i3 = this.n + 1; this.n = i3; if (i3 > 1) { this.f8200k = true; i2 = this.f8201l; this.f8201l = i2 + 1; } } else if (bVar != l.k0.k.b.CANCEL) { this.f8200k = true; i2 = this.f8201l; this.f8201l = i2 + 1; } } else if (!n() || (iOException instanceof l.k0.k.a)) { this.f8200k = true; if (this.f8202m == 0) { if (iOException != null) { this.f8191b.b(this.f8192c, iOException); } i2 = this.f8201l; this.f8201l = i2 + 1; } } } } }