涩里番 v4.2版本的 MD5 值为:b7af51031b798a68c7a3a9ba5a0dff66
以下内容为反编译后的 f.java 源代码,内容仅作参考
package m4;
import android.net.Uri;
import android.text.TextUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import m4.k;
public final class f {
public final Object f11340a = new Object();
public final ExecutorService f11341b = Executors.newFixedThreadPool(8);
public final Map<String, g> f11342c = new ConcurrentHashMap();
public final ServerSocket f11343d;
public final int f11344e;
public final Thread f11345f;
public final c f11346g;
public final k f11347h;
public final class a implements Runnable {
public final Socket f11348i;
public a(Socket socket) {
this.f11348i = socket;
}
@Override
public final void run() {
StringBuilder sb2;
f fVar = f.this;
Socket socket = this.f11348i;
Objects.requireNonNull(fVar);
try {
try {
d a10 = d.a(socket.getInputStream());
String J = z2.a.J(a10.f11334a);
Objects.requireNonNull(fVar.f11347h);
if ("ping".equals(J)) {
fVar.f11347h.b(socket);
} else {
fVar.a(J).c(a10, socket);
}
fVar.e(socket);
sb2 = new StringBuilder();
} catch (Throwable th) {
fVar.e(socket);
a3.c.H("Opened connections: " + fVar.b());
throw th;
}
} catch (SocketException unused) {
fVar.e(socket);
sb2 = new StringBuilder();
} catch (IOException e10) {
e = e10;
TextUtils.isEmpty(new m("Error processing request", e).getMessage());
fVar.e(socket);
sb2 = new StringBuilder();
} catch (m e11) {
e = e11;
TextUtils.isEmpty(new m("Error processing request", e).getMessage());
fVar.e(socket);
sb2 = new StringBuilder();
}
sb2.append("Opened connections: ");
sb2.append(fVar.b());
a3.c.H(sb2.toString());
}
}
public final class b implements Runnable {
public final CountDownLatch f11350i;
public b(CountDownLatch countDownLatch) {
this.f11350i = countDownLatch;
}
@Override
public final void run() {
this.f11350i.countDown();
f fVar = f.this;
Objects.requireNonNull(fVar);
while (!Thread.currentThread().isInterrupted()) {
try {
fVar.f11341b.submit(new a(fVar.f11343d.accept()));
} catch (IOException e10) {
TextUtils.isEmpty(new m("Error during waiting connection", e10).getMessage());
return;
}
}
}
}
public f(c cVar) {
this.f11346g = cVar;
try {
ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
this.f11343d = serverSocket;
int localPort = serverSocket.getLocalPort();
this.f11344e = localPort;
List<Proxy> list = i.f11365d;
ProxySelector.setDefault(new i(ProxySelector.getDefault(), localPort));
CountDownLatch countDownLatch = new CountDownLatch(1);
Thread thread = new Thread(new b(countDownLatch));
this.f11345f = thread;
thread.start();
countDownLatch.await();
this.f11347h = new k(localPort);
a3.c.H("Proxy cache server started. Is it alive? " + d());
} catch (IOException | InterruptedException e10) {
this.f11341b.shutdown();
throw new IllegalStateException("Error starting local proxy server", e10);
}
}
public final g a(String str) {
g gVar;
synchronized (this.f11340a) {
gVar = (g) this.f11342c.get(str);
if (gVar == null) {
gVar = new g(str, this.f11346g);
this.f11342c.put(str, gVar);
}
}
return gVar;
}
public final int b() {
int i2;
synchronized (this.f11340a) {
i2 = 0;
for (g gVar : this.f11342c.values()) {
i2 += gVar.f11352a.get();
}
}
return i2;
}
public final String c(String str) {
Objects.requireNonNull(str, "Url can't be null!");
c cVar = this.f11346g;
if (new File(cVar.f11327a, cVar.f11328b.R(str)).exists()) {
c cVar2 = this.f11346g;
File file = new File(cVar2.f11327a, cVar2.f11328b.R(str));
try {
((n4.d) this.f11346g.f11329c).a(file);
} catch (IOException e10) {
a3.c.G("Error touching file " + file, e10);
}
return Uri.fromFile(file).toString();
} else if (d()) {
Locale locale = Locale.US;
Object[] objArr = new Object[3];
objArr[0] = "127.0.0.1";
objArr[1] = Integer.valueOf(this.f11344e);
try {
objArr[2] = URLEncoder.encode(str, "utf-8");
return String.format(locale, "http://%s:%d/%s", objArr);
} catch (UnsupportedEncodingException e11) {
throw new RuntimeException("Error encoding url", e11);
}
} else {
return str;
}
}
public final boolean d() {
k kVar = this.f11347h;
Objects.requireNonNull(kVar);
int i2 = 70;
int i10 = 0;
while (i10 < 3) {
try {
} catch (InterruptedException e10) {
e = e10;
a3.c.G("Error pinging server due to unexpected error", e);
} catch (ExecutionException e11) {
e = e11;
a3.c.G("Error pinging server due to unexpected error", e);
} catch (TimeoutException unused) {
a3.c.I("Error pinging server (attempt: " + i10 + ", timeout: " + i2 + "). ");
}
if (((Boolean) kVar.f11369a.submit(new k.a()).get(i2, TimeUnit.MILLISECONDS)).booleanValue()) {
return true;
}
i10++;
i2 *= 2;
}
Locale locale = Locale.US;
Object[] objArr = new Object[3];
objArr[0] = Integer.valueOf(i10);
objArr[1] = Integer.valueOf(i2 / 2);
try {
objArr[2] = ProxySelector.getDefault().select(new URI(kVar.a()));
String format = String.format(locale, "Error pinging server (attempts: %d, max timeout: %d). If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. Default proxies are: %s", objArr);
a3.c.G(format, new m(format));
return false;
} catch (URISyntaxException e12) {
throw new IllegalStateException(e12);
}
}
public final void e(Socket socket) {
try {
if (!socket.isInputShutdown()) {
socket.shutdownInput();
}
} catch (SocketException | IOException unused) {
}
try {
if (!socket.isOutputShutdown()) {
socket.shutdownOutput();
}
} catch (IOException e10) {
a3.c.I(e10.getMessage());
}
try {
if (socket.isClosed()) {
return;
}
socket.close();
} catch (IOException unused2) {
}
}
public final void f(m4.b bVar) {
Objects.requireNonNull(bVar);
synchronized (this.f11340a) {
for (g gVar : this.f11342c.values()) {
gVar.f11355d.remove(bVar);
}
}
}
}