导航菜单

页面标题

页面副标题

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

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

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


package amc.cd.p1561;

import amc.cd.p356.C2235;
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 C9992 {

    public boolean f15630;

    public boolean f15631;

    public C9995 f15632;

    public int f15633;

    public ServerSocket f15634;

    public String f15635;

    public static class C9994 {

        public static C9992 f15636 = new C9992();
    }

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

        @Override
        public void run() {
            Socket socket;
            Throwable th;
            Exception e;
            LineNumberReader lineNumberReader;
            if (C9992.this.f15634 == null) {
                return;
            }
            while (C9992.this.f15634 != null) {
                Socket socket2 = null;
                try {
                    socket = C9992.this.f15634.accept();
                    try {
                        try {
                            lineNumberReader = new LineNumberReader(new InputStreamReader(socket.getInputStream()));
                        } catch (Throwable th2) {
                            th = th2;
                            C9992.this.m14076(socket);
                            throw th;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        C9992.this.m14079(e);
                        System.err.println(e.toString());
                        C9992.this.m14076(socket);
                    }
                } catch (Exception e3) {
                    socket = null;
                    e = e3;
                } catch (Throwable th3) {
                    socket = null;
                    th = th3;
                }
                if (C9992.this.f15635.equals(lineNumberReader.readLine())) {
                    OutputStream outputStream = socket.getOutputStream();
                    String readLine = lineNumberReader.readLine();
                    C9992.this.m14075("command=%s", readLine);
                    if ("stop".equals(readLine)) {
                        C9992.this.m14075("Issuing graceful shutdown..", new Object[0]);
                        C2235.m3368().run();
                        C9992.this.m14075("Informing client that we are stopped.", new Object[0]);
                        outputStream.write("Stopped\r\n".getBytes("UTF-8"));
                        outputStream.flush();
                        C9992.this.m14075("Shutting down monitor", new Object[0]);
                        C9992.this.m14076(socket);
                        C9992 c9992 = C9992.this;
                        c9992.m14077(c9992.f15634);
                        C9992.this.f15634 = null;
                        if (C9992.this.f15630) {
                            C9992.this.m14075("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;
                    }
                    C9992.this.m14076(socket2);
                } else {
                    System.err.println("Ignoring command with incorrect key");
                    C9992.this.m14076(socket);
                }
            }
        }

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

        public final void m14080() {
            if (C9992.this.f15633 < 0) {
                if (C9992.this.f15631) {
                    System.err.println("ShutdownMonitor not in use (port < 0): " + C9992.this.f15633);
                    return;
                }
                return;
            }
            try {
                try {
                    C9992.this.f15634 = new ServerSocket(C9992.this.f15633, 1, InetAddress.getByName("127.0.0.1"));
                    if (C9992.this.f15633 == 0) {
                        C9992 c9992 = C9992.this;
                        c9992.f15633 = c9992.f15634.getLocalPort();
                        System.out.printf("STOP.PORT=%d%n", Integer.valueOf(C9992.this.f15633));
                    }
                    if (C9992.this.f15635 == null) {
                        C9992.this.f15635 = Long.toString((long) ((Math.random() * 9.223372036854776E18d) + hashCode() + System.currentTimeMillis()), 36);
                        System.out.printf("STOP.KEY=%s%n", C9992.this.f15635);
                    }
                    C9992 c99922 = C9992.this;
                    c99922.m14075("STOP.PORT=%d", Integer.valueOf(c99922.f15633));
                    C9992 c99923 = C9992.this;
                    c99923.m14075("STOP.KEY=%s", c99923.f15635);
                    C9992 c99924 = C9992.this;
                    c99924.m14075("%s", c99924.f15634);
                } catch (Exception e) {
                    C9992.this.m14079(e);
                    System.err.println("Error binding monitor port " + C9992.this.f15633 + ": " + e.toString());
                    C9992.this.f15634 = null;
                    C9992 c99925 = C9992.this;
                    c99925.m14075("STOP.PORT=%d", Integer.valueOf(c99925.f15633));
                    C9992 c99926 = C9992.this;
                    c99926.m14075("STOP.KEY=%s", c99926.f15635);
                    C9992 c99927 = C9992.this;
                    c99927.m14075("%s", c99927.f15634);
                }
            } catch (Throwable th) {
                C9992 c99928 = C9992.this;
                c99928.m14075("STOP.PORT=%d", Integer.valueOf(c99928.f15633));
                C9992 c99929 = C9992.this;
                c99929.m14075("STOP.KEY=%s", c99929.f15635);
                C9992 c999210 = C9992.this;
                c999210.m14075("%s", c999210.f15634);
                throw th;
            }
        }
    }

    public static C9992 m14070() {
        return C9994.f15636;
    }

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

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

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

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

    public void m14078() throws Exception {
        synchronized (this) {
            C9995 c9995 = this.f15632;
            if (c9995 != null && c9995.isAlive()) {
                System.err.printf("ShutdownMonitorThread already started", new Object[0]);
                return;
            }
            C9995 c99952 = new C9995();
            this.f15632 = c99952;
            c99952.start();
        }
    }

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

    public C9992() {
        Properties properties = System.getProperties();
        this.f15631 = properties.containsKey("DEBUG");
        this.f15633 = Integer.parseInt(properties.getProperty("STOP.PORT", "-1"));
        this.f15635 = properties.getProperty("STOP.KEY", null);
        this.f15630 = true;
    }
}