正在查看: jsgt v4.8.1 应用的 f.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: jsgt v4.8.1 应用的 f.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package w;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
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.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
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 w.n.a;
import x.d;
import x.e;
public final class f {
public final Object a = new Object();
public final ExecutorService b = Executors.newFixedThreadPool(8);
public final ConcurrentHashMap c = new ConcurrentHashMap();
public final ServerSocket f1496d;
public final int f1497e;
public final Thread f1498f;
public final c f1499g;
public final n f1500h;
public final class a implements Runnable {
public final Socket a;
public a(Socket socket) {
this.a = socket;
}
@Override
public final void run() {
throw new UnsupportedOperationException("Method not decompiled: w.f.a.run():void");
}
}
public final class b implements Runnable {
public final CountDownLatch a;
public b(CountDownLatch countDownLatch) {
this.a = countDownLatch;
}
@Override
public final void run() {
this.a.countDown();
f fVar = f.this;
fVar.getClass();
while (!Thread.currentThread().isInterrupted()) {
try {
fVar.b.submit(fVar.new a(fVar.f1496d.accept()));
} catch (IOException e10) {
String message = new p("Error during waiting connection", e10).getMessage();
if (TextUtils.isEmpty(message)) {
return;
}
Log.e("HttpProxyCacheServer error", message);
return;
}
}
}
}
public f(c cVar) {
this.f1499g = cVar;
try {
ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
this.f1496d = serverSocket;
int localPort = serverSocket.getLocalPort();
this.f1497e = localPort;
List<Proxy> list = l.f1504d;
ProxySelector.setDefault(new l(ProxySelector.getDefault(), localPort));
CountDownLatch countDownLatch = new CountDownLatch(1);
Thread thread = new Thread(new b(countDownLatch));
this.f1498f = thread;
thread.start();
countDownLatch.await();
this.f1500h = new n(localPort);
a0.c.b0("Proxy cache server started. Is it alive? " + d());
} catch (IOException | InterruptedException e10) {
this.b.shutdown();
throw new IllegalStateException("Error starting local proxy server", e10);
}
}
public static void e(Socket socket) {
try {
if (!socket.isInputShutdown()) {
socket.shutdownInput();
}
} catch (SocketException | IOException unused) {
}
try {
if (!socket.isOutputShutdown()) {
socket.shutdownOutput();
}
} catch (IOException e10) {
String message = e10.getMessage();
if (message != null && !TextUtils.isEmpty(message)) {
Log.w("Failed to close socket on proxy side: {}. It seems client have already closed connection.", message);
}
}
try {
if (socket.isClosed()) {
return;
}
socket.close();
} catch (IOException unused2) {
}
}
public final g a(String str) throws p {
g gVar;
synchronized (this.a) {
gVar = (g) this.c.get(str);
if (gVar == null) {
gVar = new g(str, this.f1499g);
this.c.put(str, gVar);
}
}
return gVar;
}
public final int b() {
int i;
synchronized (this.a) {
Iterator it = this.c.values().iterator();
i = 0;
while (it.hasNext()) {
i += ((g) it.next()).a.get();
}
}
return i;
}
public final String c(String str) {
if (str == null) {
throw new NullPointerException("Url can't be null!");
}
c cVar = this.f1499g;
if (new File(cVar.a, cVar.b.e(str)).exists()) {
final File file = new File(cVar.a, cVar.b.e(str));
try {
final e eVar = cVar.c;
eVar.getClass();
eVar.a.submit(new Callable<Void>(eVar, file) {
public final File a;
public final e b;
{
this.a = file;
}
@Override
public final Void call() throws Exception {
f fVar = this.b;
fVar.getClass();
File file2 = this.a;
long j8 = 0;
if (file2.exists()) {
long currentTimeMillis = System.currentTimeMillis();
if (!file2.setLastModified(currentTimeMillis)) {
long length = file2.length();
if (length != 0) {
RandomAccessFile randomAccessFile = new RandomAccessFile(file2, "rwd");
long j10 = length - 1;
randomAccessFile.seek(j10);
byte readByte = randomAccessFile.readByte();
randomAccessFile.seek(j10);
randomAccessFile.write(readByte);
randomAccessFile.close();
} else if (!file2.delete() || !file2.createNewFile()) {
throw new IOException("Error recreate zero-size file " + file2);
}
if (file2.lastModified() < currentTimeMillis) {
String str2 = new Date(file2.lastModified()).toString() + "\n" + file2.getAbsolutePath();
if (str2 != null && !TextUtils.isEmpty(str2)) {
Log.w("Last modified date {} is not set for file {}", str2);
}
}
}
}
File parentFile = file2.getParentFile();
List<File> linkedList = new LinkedList();
File[] listFiles = parentFile.listFiles();
if (listFiles != null) {
linkedList = Arrays.asList(listFiles);
Collections.sort(linkedList, new d.a());
}
Iterator it = linkedList.iterator();
while (it.hasNext()) {
j8 += ((File) it.next()).length();
}
linkedList.size();
for (File file3 : linkedList) {
if (!(j8 <= fVar.b)) {
long length2 = file3.length();
if (file3.delete()) {
j8 -= length2;
a0.c.b0("Cache file " + file3 + " is deleted because it exceeds cache limit");
} else {
String str3 = "Error deleting file " + file3 + " for trimming cache";
if (!TextUtils.isEmpty(str3)) {
Log.e("HttpProxyCacheDebuger", str3);
}
}
}
}
return null;
}
});
} catch (IOException e10) {
a0.c.a0("Error touching file " + file, e10);
}
return Uri.fromFile(file).toString();
}
if (!d()) {
return str;
}
Locale locale = Locale.US;
Object[] objArr = new Object[3];
objArr[0] = "127.0.0.1";
objArr[1] = Integer.valueOf(this.f1497e);
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);
}
}
public final boolean d() {
n nVar = this.f1500h;
nVar.getClass();
int i = 70;
int i10 = 0;
while (i10 < 3) {
try {
} catch (InterruptedException e10) {
e = e10;
a0.c.a0("Error pinging server due to unexpected error", e);
} catch (ExecutionException e11) {
e = e11;
a0.c.a0("Error pinging server due to unexpected error", e);
} catch (TimeoutException unused) {
a0.c.c0("Error pinging server (attempt: " + i10 + ", timeout: " + i + "). ");
}
if (((Boolean) nVar.a.submit(nVar.new a()).get(i, TimeUnit.MILLISECONDS)).booleanValue()) {
return true;
}
i10++;
i *= 2;
}
Locale locale = Locale.US;
Object[] objArr = new Object[3];
objArr[0] = Integer.valueOf(i10);
objArr[1] = Integer.valueOf(i / 2);
try {
objArr[2] = ProxySelector.getDefault().select(new URI(nVar.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);
a0.c.a0(format, new p(format));
return false;
} catch (URISyntaxException e12) {
throw new IllegalStateException(e12);
}
}
public final void f(w.b bVar) {
bVar.getClass();
synchronized (this.a) {
Iterator it = this.c.values().iterator();
while (it.hasNext()) {
((g) it.next()).f1501d.remove(bVar);
}
}
}
}