Spermatid v6.1.8版本的 MD5 值为:a375ce51a42d528ba6e2583c10478296
以下内容为反编译后的 HttpProxyCacheServer.java 源代码,内容仅作参考
package com.danikula.videocache;
import android.content.Context;
import c3.h;
import com.kwai.video.player.KsMediaMeta;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class HttpProxyCacheServer {
public final Object f9785a;
public final ExecutorService f9786b;
public final Map<String, d> f9787c;
public final ServerSocket f9788d;
public final int f9789e;
public final Thread f9790f;
public final c3.b f9791g;
public static final class Builder {
public File f9792a;
public f3.b f9795d;
public d3.a f9794c = new d3.g(KsMediaMeta.AV_CH_STEREO_LEFT);
public d3.c f9793b = new d3.f();
public e3.b f9796e = new e3.a();
public Builder(Context context) {
this.f9795d = f3.c.a(context);
this.f9792a = h.b(context);
}
public final c3.b b() {
return new c3.b(this.f9792a, this.f9793b, this.f9794c, this.f9795d, this.f9796e);
}
}
public final class a implements Runnable {
public final Socket f9797a;
public a(Socket socket) {
this.f9797a = socket;
}
@Override
public void run() {
HttpProxyCacheServer.this.i(this.f9797a);
}
}
public final class b implements Runnable {
public final CountDownLatch f9799a;
public b(CountDownLatch countDownLatch) {
this.f9799a = countDownLatch;
}
@Override
public void run() {
this.f9799a.countDown();
HttpProxyCacheServer.this.k();
}
}
public HttpProxyCacheServer(Context context) {
this(new Builder(context).b());
}
public final void c(Socket socket) {
try {
if (socket.isClosed()) {
return;
}
socket.close();
} catch (IOException e10) {
h(new ProxyCacheException("Error closing socket", e10));
}
}
public final void d(Socket socket) {
try {
if (socket.isInputShutdown()) {
return;
}
socket.shutdownInput();
} catch (SocketException unused) {
c3.d.a("Releasing input stream… Socket is closed by client.");
} catch (IOException e10) {
h(new ProxyCacheException("Error closing socket input stream", e10));
}
}
public final void e(Socket socket) {
try {
if (socket.isOutputShutdown()) {
return;
}
socket.shutdownOutput();
} catch (IOException unused) {
c3.d.d("Failed to close socket on proxy side: {}. It seems client have already closed connection.");
}
}
public final d f(String str) throws ProxyCacheException {
d dVar;
synchronized (this.f9785a) {
dVar = this.f9787c.get(str);
if (dVar == null) {
dVar = new d(str, this.f9791g);
this.f9787c.put(str, dVar);
}
}
return dVar;
}
public final int g() {
int i10;
synchronized (this.f9785a) {
i10 = 0;
Iterator<d> it = this.f9787c.values().iterator();
while (it.hasNext()) {
i10 += it.next().b();
}
}
return i10;
}
public final void h(Throwable th) {
c3.d.b("HttpProxyCacheServer error");
}
public final void i(Socket socket) {
?? r52;
?? r02 = "Opened connections: ";
try {
try {
com.danikula.videocache.b c10 = com.danikula.videocache.b.c(socket.getInputStream());
c3.d.a("Request to cache proxy:" + c10);
f(c3.f.e(c10.f9803a)).d(c10, socket);
j(socket);
r52 = new StringBuilder();
} catch (ProxyCacheException e10) {
e = e10;
h(new ProxyCacheException("Error processing request", e));
j(socket);
r52 = new StringBuilder();
} catch (SocketException unused) {
c3.d.a("Closing socket… Socket is closed by client.");
j(socket);
r52 = new StringBuilder();
} catch (IOException e11) {
e = e11;
h(new ProxyCacheException("Error processing request", e));
j(socket);
r52 = new StringBuilder();
}
r52.append("Opened connections: ");
r02 = g();
r52.append(r02);
socket = r52.toString();
c3.d.a(socket);
} catch (Throwable th) {
j(socket);
?? sb2 = new StringBuilder();
sb2.append(r02);
sb2.append(g());
c3.d.a(sb2.toString());
throw th;
}
}
public final void j(Socket socket) {
d(socket);
e(socket);
c(socket);
}
public final void k() {
while (!Thread.currentThread().isInterrupted()) {
try {
Socket accept = this.f9788d.accept();
c3.d.a("Accept new socket " + accept);
this.f9786b.submit(new a(accept));
} catch (IOException e10) {
h(new ProxyCacheException("Error during waiting connection", e10));
return;
}
}
}
public HttpProxyCacheServer(c3.b bVar) {
this.f9785a = new Object();
this.f9786b = Executors.newFixedThreadPool(8);
this.f9787c = new ConcurrentHashMap();
this.f9791g = (c3.b) c3.e.c(bVar);
try {
ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
this.f9788d = serverSocket;
int localPort = serverSocket.getLocalPort();
this.f9789e = localPort;
c3.c.a("127.0.0.1", localPort);
CountDownLatch countDownLatch = new CountDownLatch(1);
Thread thread = new Thread(new b(countDownLatch));
this.f9790f = thread;
thread.start();
countDownLatch.await();
} catch (IOException | InterruptedException e10) {
this.f9786b.shutdown();
throw new IllegalStateException("Error starting local proxy server", e10);
}
}
}