91快播 v3.3.0版本的 MD5 值为:094b9519ad2388a8147509cb8a126145

以下内容为反编译后的 C2640.java 源代码,内容仅作参考


package anta.ᆁ;

import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import anta.ᆁ.C2633;
import anta.Ⰲ.AbstractC6038;
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;
public class C2640 {
    public final int f6332;
    public final ServerSocket f6334;
    public final C2633 f6335;
    public final Thread f6336;
    public final C2623 f6337;
    public final Object f6330 = new Object();
    public final ExecutorService f6333 = Executors.newFixedThreadPool(8);
    public final Map<String, C2637> f6331 = new ConcurrentHashMap();

    public final class RunnableC2642 implements Runnable {
        public final CountDownLatch f6338;

        public RunnableC2642(CountDownLatch countDownLatch) {
            this.f6338 = countDownLatch;
        }

        @Override
        public void run() {
            this.f6338.countDown();
            C2640 c2640 = C2640.this;
            Objects.requireNonNull(c2640);
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    c2640.f6333.submit(new RunnableC2643(c2640.f6334.accept()));
                } catch (IOException e) {
                    c2640.m2683(new C2628("Error during waiting connection", e));
                    return;
                }
            }
        }
    }

    public final class RunnableC2643 implements Runnable {
        public final Socket f6339;

        public RunnableC2643(Socket socket) {
            this.f6339 = socket;
        }

        @Override
        public void run() {
            StringBuilder sb;
            C2640 c2640 = C2640.this;
            Socket socket = this.f6339;
            Objects.requireNonNull(c2640);
            try {
                try {
                    C2632 m2672 = C2632.m2672(socket.getInputStream());
                    String m2668 = C2625.m2668(m2672.f6313);
                    Objects.requireNonNull(c2640.f6335);
                    if ("ping".equals(m2668)) {
                        c2640.f6335.m2674(socket);
                    } else {
                        c2640.m2681(m2668).m2676(m2672, socket);
                    }
                    c2640.m2686(socket);
                    sb = new StringBuilder();
                } catch (Throwable th) {
                    c2640.m2686(socket);
                    C2639.m2680("Opened connections: " + c2640.m2684());
                    throw th;
                }
            } catch (C2628 e) {
                e = e;
                c2640.m2683(new C2628("Error processing request", e));
                c2640.m2686(socket);
                sb = new StringBuilder();
            } catch (SocketException unused) {
                c2640.m2686(socket);
                sb = new StringBuilder();
            } catch (IOException e2) {
                e = e2;
                c2640.m2683(new C2628("Error processing request", e));
                c2640.m2686(socket);
                sb = new StringBuilder();
            }
            sb.append("Opened connections: ");
            sb.append(c2640.m2684());
            C2639.m2680(sb.toString());
        }
    }

    public C2640(C2623 c2623, C2641 c2641) {
        this.f6337 = c2623;
        try {
            ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
            this.f6334 = serverSocket;
            int localPort = serverSocket.getLocalPort();
            this.f6332 = localPort;
            List<Proxy> list = C2629.f6307;
            ProxySelector.setDefault(new C2629(ProxySelector.getDefault(), "127.0.0.1", localPort));
            CountDownLatch countDownLatch = new CountDownLatch(1);
            Thread thread = new Thread(new RunnableC2642(countDownLatch));
            this.f6336 = thread;
            thread.start();
            countDownLatch.await();
            this.f6335 = new C2633("127.0.0.1", localPort);
            C2639.m2680("Proxy cache server started. Is it alive? " + m2685());
        } catch (IOException | InterruptedException e) {
            this.f6333.shutdown();
            throw new IllegalStateException("Error starting local proxy server", e);
        }
    }

    public final C2637 m2681(String str) {
        C2637 c2637;
        synchronized (this.f6330) {
            c2637 = this.f6331.get(str);
            if (c2637 == null) {
                c2637 = new C2637(str, this.f6337);
                this.f6331.put(str, c2637);
            }
        }
        return c2637;
    }

    public String m2682(String str) {
        Objects.requireNonNull(str, "Url can't be null!");
        C2623 c2623 = this.f6337;
        if (new File(c2623.f6290, c2623.f6293.mo5618(str)).exists()) {
            C2623 c26232 = this.f6337;
            File file = new File(c26232.f6290, c26232.f6293.mo5618(str));
            try {
                AbstractC6038 abstractC6038 = (AbstractC6038) this.f6337.f6291;
                abstractC6038.f14029.submit(new AbstractC6038.CallableC6039(file));
            } catch (IOException e) {
                C2639.m2678("Error touching file " + file, e);
            }
            return Uri.fromFile(file).toString();
        } else if (m2685()) {
            Locale locale = Locale.US;
            Object[] objArr = new Object[3];
            objArr[0] = "127.0.0.1";
            objArr[1] = Integer.valueOf(this.f6332);
            try {
                objArr[2] = URLEncoder.encode(str, "utf-8");
                return String.format(locale, "http://%s:%d/%s", objArr);
            } catch (UnsupportedEncodingException e2) {
                throw new RuntimeException("Error encoding url", e2);
            }
        } else {
            return str;
        }
    }

    public final void m2683(Throwable th) {
        String message = th.getMessage();
        if (TextUtils.isEmpty(message)) {
            return;
        }
        Log.e("HttpProxyCacheServer error", message);
    }

    public final int m2684() {
        int i;
        synchronized (this.f6330) {
            i = 0;
            for (C2637 c2637 : this.f6331.values()) {
                i += c2637.f6322.get();
            }
        }
        return i;
    }

    public final boolean m2685() {
        C2633 c2633 = this.f6335;
        Objects.requireNonNull(c2633);
        int i = 70;
        int i2 = 0;
        while (i2 < 3) {
            try {
            } catch (InterruptedException e) {
                e = e;
                C2639.m2678("Error pinging server due to unexpected error", e);
            } catch (ExecutionException e2) {
                e = e2;
                C2639.m2678("Error pinging server due to unexpected error", e);
            } catch (TimeoutException unused) {
                C2639.m2679("HttpProxyCacheDebuger", "Error pinging server (attempt: " + i2 + ", timeout: " + i + "). ");
            }
            if (((Boolean) c2633.f6316.submit(new C2633.CallableC2635(null)).get(i, TimeUnit.MILLISECONDS)).booleanValue()) {
                return true;
            }
            i2++;
            i *= 2;
        }
        Locale locale = Locale.US;
        Object[] objArr = new Object[3];
        objArr[0] = Integer.valueOf(i2);
        objArr[1] = Integer.valueOf(i / 2);
        try {
            objArr[2] = ProxySelector.getDefault().select(new URI(c2633.m2673()));
            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);
            C2639.m2678(format, new C2628(format));
            return false;
        } catch (URISyntaxException e3) {
            throw new IllegalStateException(e3);
        }
    }

    public final void m2686(Socket socket) {
        try {
            if (!socket.isInputShutdown()) {
                socket.shutdownInput();
            }
        } catch (SocketException | IOException unused) {
        }
        try {
            if (!socket.isOutputShutdown()) {
                socket.shutdownOutput();
            }
        } catch (IOException e) {
            C2639.m2679("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage());
        }
        try {
            if (socket.isClosed()) {
                return;
            }
            socket.close();
        } catch (IOException unused2) {
        }
    }

    public void m2687(InterfaceC2630 interfaceC2630) {
        synchronized (this.f6330) {
            for (C2637 c2637 : this.f6331.values()) {
                c2637.f6323.remove(interfaceC2630);
            }
        }
    }
}