导航菜单

页面标题

页面副标题

远离手机 v4.9.11 - IlI1Il1llI1l.java 源代码

正在查看: 远离手机 v4.9.11 应用的 IlI1Il1llI1l.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.lijianqiang12.silent;

import android.content.Context;
import android.net.Uri;
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.Locale;
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 IlI1Il1llI1l {
    private static final String IIll11IllI1l = "127.0.0.1";
    private static final IlIl11IIIl Ill1llIIlIlll = II11l1lI11.IIll11IllI1l("HttpProxyCacheServer");
    private final Object IIllIl1llII;
    private final Map<String, I11ll1I11I1Il> Il11lI1III1;
    private final int Il1IlII1;
    private final ExecutorService IlllIll1I1I;
    private final Thread lI11111lI1;
    private final II11I111III1 lI111l1I1llIl;
    private final I11IIlI11l lII1lI1Illl;
    private final ServerSocket lIIl1I1I;

    private final class Il11lI1III1 implements Runnable {
        private final Socket Il11lIlllll1;

        public Il11lI1III1(Socket socket) {
            this.Il11lIlllll1 = socket;
        }

        @Override
        public void run() {
            IlI1Il1llI1l.this.III11IIll1lI1(this.Il11lIlllll1);
        }
    }

    public static final class IlllIll1I1I {
        private static final long lI11111lI1 = 536870912;
        private File IIllIl1llII;
        private Ill1Ill11 lIIl1I1I;
        private lIlI11I1IIl1 Il11lI1III1 = new lI11l1l11I1(lI11111lI1);
        private llll1Ill1l IlllIll1I1I = new IlIllIlllI1();
        private I11lI1l1lI11 Il1IlII1 = new lIllI1lIlllI1();

        public IlllIll1I1I(Context context) {
            this.lIIl1I1I = I1lll111IlIIl.IlllIll1I1I(context);
            this.IIllIl1llII = I111ll11I1ll.Il11lI1III1(context);
        }

        public I11IIlI11l Il11lI1III1() {
            return new I11IIlI11l(this.IIllIl1llII, this.IlllIll1I1I, this.Il11lI1III1, this.lIIl1I1I, this.Il1IlII1);
        }

        public IlllIll1I1I Il1IlII1(lIlI11I1IIl1 lili11i1iil1) {
            this.Il11lI1III1 = (lIlI11I1IIl1) I1l1lll1lIl.lIIl1I1I(lili11i1iil1);
            return this;
        }

        public IlllIll1I1I Ill1llIIlIlll(long j) {
            this.Il11lI1III1 = new lI11l1l11I1(j);
            return this;
        }

        public IlI1Il1llI1l IlllIll1I1I() {
            return new IlI1Il1llI1l(Il11lI1III1());
        }

        public IlllIll1I1I lI11111lI1(llll1Ill1l llll1ill1l) {
            this.IlllIll1I1I = (llll1Ill1l) I1l1lll1lIl.lIIl1I1I(llll1ill1l);
            return this;
        }

        public IlllIll1I1I lI111l1I1llIl(int i) {
            this.Il11lI1III1 = new III1l1lII11I(i);
            return this;
        }

        public IlllIll1I1I lII1lI1Illl(I11lI1l1lI11 i11lI1l1lI11) {
            this.Il1IlII1 = (I11lI1l1lI11) I1l1lll1lIl.lIIl1I1I(i11lI1l1lI11);
            return this;
        }

        public IlllIll1I1I lIIl1I1I(File file) {
            this.IIllIl1llII = (File) I1l1lll1lIl.lIIl1I1I(file);
            return this;
        }
    }

    private final class lIIl1I1I implements Runnable {
        private final CountDownLatch Il11lIlllll1;

        public lIIl1I1I(CountDownLatch countDownLatch) {
            this.Il11lIlllll1 = countDownLatch;
        }

        @Override
        public void run() {
            this.Il11lIlllll1.countDown();
            IlI1Il1llI1l.this.lI1l11l11ll();
        }
    }

    private void I11ll1l1lI11l(Socket socket) {
        Il1IlII1(socket);
        lI11111lI1(socket);
        lIIl1I1I(socket);
    }

    public void III11IIll1lI1(Socket socket) {
        try {
            try {
                III1Il1lll1 Il11lI1III12 = III1Il1lll1.Il11lI1III1(socket.getInputStream());
                IlIl11IIIl ilIl11IIIl = Ill1llIIlIlll;
                ilIl11IIIl.IlllIll1I1I("Request to cache proxy:" + Il11lI1III12);
                String Il1IlII1 = ll1II1lIlI1.Il1IlII1(Il11lI1III12.IIllIl1llII);
                if (this.lI111l1I1llIl.lIIl1I1I(Il1IlII1)) {
                    this.lI111l1I1llIl.lII1lI1Illl(socket);
                } else {
                    lI111l1I1llIl(Il1IlII1).lIIl1I1I(Il11lI1III12, socket);
                }
                I11ll1l1lI11l(socket);
                ilIl11IIIl.IlllIll1I1I("Opened connections: " + Ill1llIIlIlll());
            } catch (II1lllIIIl e) {
                e = e;
                l1llllI11l111(new II1lllIIIl("Error processing request", e));
                I11ll1l1lI11l(socket);
                Ill1llIIlIlll.IlllIll1I1I("Opened connections: " + Ill1llIIlIlll());
            } catch (SocketException unused) {
                IlIl11IIIl ilIl11IIIl2 = Ill1llIIlIlll;
                ilIl11IIIl2.IlllIll1I1I("Closing socket… Socket is closed by client.");
                I11ll1l1lI11l(socket);
                ilIl11IIIl2.IlllIll1I1I("Opened connections: " + Ill1llIIlIlll());
            } catch (IOException e2) {
                e = e2;
                l1llllI11l111(new II1lllIIIl("Error processing request", e));
                I11ll1l1lI11l(socket);
                Ill1llIIlIlll.IlllIll1I1I("Opened connections: " + Ill1llIIlIlll());
            }
        } catch (Throwable th) {
            I11ll1l1lI11l(socket);
            Ill1llIIlIlll.IlllIll1I1I("Opened connections: " + Ill1llIIlIlll());
            throw th;
        }
    }

    private void IIIII11lIlIl() {
        synchronized (this.IIllIl1llII) {
            try {
                Iterator<I11ll1I11I1Il> it = this.Il11lI1III1.values().iterator();
                while (it.hasNext()) {
                    it.next().lI11111lI1();
                }
                this.Il11lI1III1.clear();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    private String Il11lI1III1(String str) {
        return String.format(Locale.US, "http://%s:%d/%s", IIll11IllI1l, Integer.valueOf(this.Il1IlII1), ll1II1lIlI1.lI11111lI1(str));
    }

    private void Il1IlII1(Socket socket) {
        try {
            if (socket.isInputShutdown()) {
                return;
            }
            socket.shutdownInput();
        } catch (SocketException unused) {
            Ill1llIIlIlll.IlllIll1I1I("Releasing input stream… Socket is closed by client.");
        } catch (IOException e) {
            l1llllI11l111(new II1lllIIIl("Error closing socket input stream", e));
        }
    }

    private int Ill1llIIlIlll() {
        int i;
        synchronized (this.IIllIl1llII) {
            try {
                Iterator<I11ll1I11I1Il> it = this.Il11lI1III1.values().iterator();
                i = 0;
                while (it.hasNext()) {
                    i += it.next().IlllIll1I1I();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return i;
    }

    private void l1llllI11l111(Throwable th) {
        Ill1llIIlIlll.IIllIl1llII("HttpProxyCacheServer error", th);
    }

    private void lI11111lI1(Socket socket) {
        try {
            if (socket.isOutputShutdown()) {
                return;
            }
            socket.shutdownOutput();
        } catch (IOException e) {
            Ill1llIIlIlll.lII1lI1Illl("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage());
        }
    }

    private I11ll1I11I1Il lI111l1I1llIl(String str) throws II1lllIIIl {
        I11ll1I11I1Il i11ll1I11I1Il;
        synchronized (this.IIllIl1llII) {
            try {
                i11ll1I11I1Il = this.Il11lI1III1.get(str);
                if (i11ll1I11I1Il == null) {
                    i11ll1I11I1Il = new I11ll1I11I1Il(str, this.lII1lI1Illl);
                    this.Il11lI1III1.put(str, i11ll1I11I1Il);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return i11ll1I11I1Il;
    }

    public void lI1l11l11ll() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                Socket accept = this.lIIl1I1I.accept();
                Ill1llIIlIlll.IlllIll1I1I("Accept new socket " + accept);
                this.IlllIll1I1I.submit(new Il11lI1III1(accept));
            } catch (IOException e) {
                l1llllI11l111(new II1lllIIIl("Error during waiting connection", e));
                return;
            }
        }
    }

    private File lII1lI1Illl(String str) {
        I11IIlI11l i11IIlI11l = this.lII1lI1Illl;
        return new File(i11IIlI11l.IIllIl1llII, i11IIlI11l.IlllIll1I1I.IIllIl1llII(str));
    }

    private void lIIl1I1I(Socket socket) {
        try {
            if (socket.isClosed()) {
                return;
            }
            socket.close();
        } catch (IOException e) {
            l1llllI11l111(new II1lllIIIl("Error closing socket", e));
        }
    }

    private boolean ll11llIII1111() {
        return this.lI111l1I1llIl.Il1IlII1(3, 70);
    }

    private void llIIlllll111(File file) {
        try {
            this.lII1lI1Illl.Il11lI1III1.IIllIl1llII(file);
        } catch (IOException e) {
            Ill1llIIlIlll.IIllIl1llII("Error touching file " + file, e);
        }
    }

    public String I1Il11llllIl(String str, boolean z) {
        if (!z || !IllIlI1l1I(str)) {
            return ll11llIII1111() ? Il11lI1III1(str) : str;
        }
        File lII1lI1Illl = lII1lI1Illl(str);
        llIIlllll111(lII1lI1Illl);
        return Uri.fromFile(lII1lI1Illl).toString();
    }

    public void IIl1I11I1lI1l(I111I11l1lIl1 i111I11l1lIl1, String str) {
        I1l1lll1lIl.IIllIl1llII(i111I11l1lIl1, str);
        synchronized (this.IIllIl1llII) {
            try {
                lI111l1I1llIl(str).Il1IlII1(i111I11l1lIl1);
            } catch (II1lllIIIl e) {
                Ill1llIIlIlll.I1IlIl1llII("Error registering cache listener", e);
            }
        }
    }

    public String IIll11IllI1l(String str) {
        return I1Il11llllIl(str, true);
    }

    public void IIllll1Il1lIl(I111I11l1lIl1 i111I11l1lIl1, String str) {
        I1l1lll1lIl.IIllIl1llII(i111I11l1lIl1, str);
        synchronized (this.IIllIl1llII) {
            try {
                lI111l1I1llIl(str).lI111l1I1llIl(i111I11l1lIl1);
            } catch (II1lllIIIl e) {
                Ill1llIIlIlll.I1IlIl1llII("Error registering cache listener", e);
            }
        }
    }

    public void Il11lI1l() {
        Ill1llIIlIlll.Ill11IIlII1("Shutdown proxy server");
        IIIII11lIlIl();
        this.lII1lI1Illl.lIIl1I1I.release();
        this.lI11111lI1.interrupt();
        try {
            if (this.lIIl1I1I.isClosed()) {
                return;
            }
            this.lIIl1I1I.close();
        } catch (IOException e) {
            l1llllI11l111(new II1lllIIIl("Error shutting down proxy server", e));
        }
    }

    public boolean IllIlI1l1I(String str) {
        I1l1lll1lIl.Il1IlII1(str, "Url can't be null!");
        return lII1lI1Illl(str).exists();
    }

    public void llI1l1l1Il1I(I111I11l1lIl1 i111I11l1lIl1) {
        I1l1lll1lIl.lIIl1I1I(i111I11l1lIl1);
        synchronized (this.IIllIl1llII) {
            try {
                Iterator<I11ll1I11I1Il> it = this.Il11lI1III1.values().iterator();
                while (it.hasNext()) {
                    it.next().lI111l1I1llIl(i111I11l1lIl1);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public IlI1Il1llI1l(Context context) {
        this(new IlllIll1I1I(context).Il11lI1III1());
    }

    private IlI1Il1llI1l(I11IIlI11l i11IIlI11l) {
        this.IIllIl1llII = new Object();
        this.IlllIll1I1I = Executors.newFixedThreadPool(8);
        this.Il11lI1III1 = new ConcurrentHashMap();
        this.lII1lI1Illl = (I11IIlI11l) I1l1lll1lIl.lIIl1I1I(i11IIlI11l);
        try {
            ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName(IIll11IllI1l));
            this.lIIl1I1I = serverSocket;
            int localPort = serverSocket.getLocalPort();
            this.Il1IlII1 = localPort;
            II1lIlIlI1II.IIllIl1llII(IIll11IllI1l, localPort);
            CountDownLatch countDownLatch = new CountDownLatch(1);
            Thread thread = new Thread(new lIIl1I1I(countDownLatch));
            this.lI11111lI1 = thread;
            thread.start();
            countDownLatch.await();
            this.lI111l1I1llIl = new II11I111III1(IIll11IllI1l, localPort);
            Ill1llIIlIlll.Ill11IIlII1("Proxy cache server started. Is it alive? " + ll11llIII1111());
        } catch (IOException | InterruptedException e) {
            this.IlllIll1I1I.shutdown();
            throw new IllegalStateException("Error starting local proxy server", e);
        }
    }
}