导航菜单

页面标题

页面副标题

饼干视频 v4.1.0 - C2155.java 源代码

正在查看: 饼干视频 v4.1.0 应用的 C2155.java JAVA 源代码文件

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


package amc.cd.p173;

import amc.cd.p038.C0472;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;

public class C2155 {

    public boolean f3732;

    public boolean f3733;

    public C2158 f3734;

    public int f3735;

    public ServerSocket f3736;

    public String f3737;

    public static class C2157 {

        public static C2155 f3738 = new C2155();
    }

    public class C2158 extends Thread {
        public C2158() {
            setDaemon(true);
            setName("ShutdownMonitor");
        }

        @Override
        public void run() {
            Socket socket;
            Throwable th;
            Exception e;
            LineNumberReader lineNumberReader;
            if (C2155.this.f3736 == null) {
                return;
            }
            while (C2155.this.f3736 != null) {
                Socket socket2 = null;
                try {
                    socket = C2155.this.f3736.accept();
                    try {
                        try {
                            lineNumberReader = new LineNumberReader(new InputStreamReader(socket.getInputStream()));
                        } catch (Throwable th2) {
                            th = th2;
                            C2155.this.m5766(socket);
                            throw th;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        C2155.this.m5769(e);
                        System.err.println(e.toString());
                        C2155.this.m5766(socket);
                    }
                } catch (Exception e3) {
                    socket = null;
                    e = e3;
                } catch (Throwable th3) {
                    socket = null;
                    th = th3;
                }
                if (C2155.this.f3737.equals(lineNumberReader.readLine())) {
                    OutputStream outputStream = socket.getOutputStream();
                    String readLine = lineNumberReader.readLine();
                    C2155.this.m5765("command=%s", readLine);
                    if ("stop".equals(readLine)) {
                        C2155.this.m5765("Issuing graceful shutdown..", new Object[0]);
                        C0472.m1387().run();
                        C2155.this.m5765("Informing client that we are stopped.", new Object[0]);
                        outputStream.write("Stopped\r\n".getBytes("UTF-8"));
                        outputStream.flush();
                        C2155.this.m5765("Shutting down monitor", new Object[0]);
                        C2155.this.m5766(socket);
                        C2155 c2155 = C2155.this;
                        c2155.m5767(c2155.f3736);
                        C2155.this.f3736 = null;
                        if (C2155.this.f3732) {
                            C2155.this.m5765("Killing JVM", new Object[0]);
                            System.exit(0);
                        }
                    } else {
                        if ("status".equals(readLine)) {
                            outputStream.write("OK\r\n".getBytes("UTF-8"));
                            outputStream.flush();
                        }
                        socket2 = socket;
                    }
                    C2155.this.m5766(socket2);
                } else {
                    System.err.println("Ignoring command with incorrect key");
                    C2155.this.m5766(socket);
                }
            }
        }

        @Override
        public void start() {
            if (isAlive()) {
                System.err.printf("ShutdownMonitorThread already started", new Object[0]);
                return;
            }
            m5770();
            if (C2155.this.f3736 == null) {
                return;
            }
            if (C2155.this.f3733) {
                System.err.println("Starting ShutdownMonitorThread");
            }
            super.start();
        }

        public final void m5770() {
            if (C2155.this.f3735 < 0) {
                if (C2155.this.f3733) {
                    System.err.println("ShutdownMonitor not in use (port < 0): " + C2155.this.f3735);
                    return;
                }
                return;
            }
            try {
                try {
                    C2155.this.f3736 = new ServerSocket(C2155.this.f3735, 1, InetAddress.getByName("127.0.0.1"));
                    if (C2155.this.f3735 == 0) {
                        C2155 c2155 = C2155.this;
                        c2155.f3735 = c2155.f3736.getLocalPort();
                        System.out.printf("STOP.PORT=%d%n", Integer.valueOf(C2155.this.f3735));
                    }
                    if (C2155.this.f3737 == null) {
                        C2155.this.f3737 = Long.toString((long) ((Math.random() * 9.223372036854776E18d) + hashCode() + System.currentTimeMillis()), 36);
                        System.out.printf("STOP.KEY=%s%n", C2155.this.f3737);
                    }
                    C2155 c21552 = C2155.this;
                    c21552.m5765("STOP.PORT=%d", Integer.valueOf(c21552.f3735));
                    C2155 c21553 = C2155.this;
                    c21553.m5765("STOP.KEY=%s", c21553.f3737);
                    C2155 c21554 = C2155.this;
                    c21554.m5765("%s", c21554.f3736);
                } catch (Exception e) {
                    C2155.this.m5769(e);
                    System.err.println("Error binding monitor port " + C2155.this.f3735 + ": " + e.toString());
                    C2155.this.f3736 = null;
                    C2155 c21555 = C2155.this;
                    c21555.m5765("STOP.PORT=%d", Integer.valueOf(c21555.f3735));
                    C2155 c21556 = C2155.this;
                    c21556.m5765("STOP.KEY=%s", c21556.f3737);
                    C2155 c21557 = C2155.this;
                    c21557.m5765("%s", c21557.f3736);
                }
            } catch (Throwable th) {
                C2155 c21558 = C2155.this;
                c21558.m5765("STOP.PORT=%d", Integer.valueOf(c21558.f3735));
                C2155 c21559 = C2155.this;
                c21559.m5765("STOP.KEY=%s", c21559.f3737);
                C2155 c215510 = C2155.this;
                c215510.m5765("%s", c215510.f3736);
                throw th;
            }
        }
    }

    public static C2155 m5760() {
        return C2157.f3738;
    }

    public String toString() {
        return String.format("%s[port=%d]", getClass().getName(), Integer.valueOf(this.f3735));
    }

    public final void m5765(String str, Object... objArr) {
        if (this.f3733) {
            System.err.printf("[ShutdownMonitor] " + str + "%n", objArr);
        }
    }

    public final void m5766(Socket socket) {
        if (socket == null) {
            return;
        }
        try {
            socket.close();
        } catch (IOException unused) {
        }
    }

    public final void m5767(ServerSocket serverSocket) {
        if (serverSocket == null) {
            return;
        }
        try {
            serverSocket.close();
        } catch (IOException unused) {
        }
    }

    public void m5768() throws Exception {
        synchronized (this) {
            C2158 c2158 = this.f3734;
            if (c2158 != null && c2158.isAlive()) {
                System.err.printf("ShutdownMonitorThread already started", new Object[0]);
                return;
            }
            C2158 c21582 = new C2158();
            this.f3734 = c21582;
            c21582.start();
        }
    }

    public final void m5769(Throwable th) {
        if (this.f3733) {
            th.printStackTrace(System.err);
        }
    }

    public C2155() {
        Properties properties = System.getProperties();
        this.f3733 = properties.containsKey("DEBUG");
        this.f3735 = Integer.parseInt(properties.getProperty("STOP.PORT", "-1"));
        this.f3737 = properties.getProperty("STOP.KEY", null);
        this.f3732 = true;
    }
}