鑫垚影视 v20.42版本的 MD5 值为:e3822d25ef47121f1770bb4806abacfe
以下内容为反编译后的 b0.java 源代码,内容仅作参考
package n.b.a.f;
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 b0 {
private boolean f21180a;
private int f21181b;
private String f21182c;
private boolean f21183d;
private ServerSocket f21184e;
private c f21185f;
public static class b {
public static b0 f21186a = new b0();
}
public class c extends Thread {
public c() {
setDaemon(true);
setName("ShutdownMonitor");
}
private void a() {
if (b0.this.f21181b < 0) {
if (b0.this.f21180a) {
System.err.println("ShutdownMonitor not in use (port < 0): " + b0.this.f21181b);
return;
}
return;
}
try {
try {
b0.this.f21184e = new ServerSocket(b0.this.f21181b, 1, InetAddress.getByName("127.0.0.1"));
if (b0.this.f21181b == 0) {
b0 b0Var = b0.this;
b0Var.f21181b = b0Var.f21184e.getLocalPort();
System.out.printf("STOP.PORT=%d%n", Integer.valueOf(b0.this.f21181b));
}
if (b0.this.f21182c == null) {
b0.this.f21182c = Long.toString((long) ((Math.random() * 9.223372036854776E18d) + hashCode() + System.currentTimeMillis()), 36);
System.out.printf("STOP.KEY=%s%n", b0.this.f21182c);
}
b0 b0Var2 = b0.this;
b0Var2.o("STOP.PORT=%d", Integer.valueOf(b0Var2.f21181b));
b0 b0Var3 = b0.this;
b0Var3.o("STOP.KEY=%s", b0Var3.f21182c);
b0 b0Var4 = b0.this;
b0Var4.o("%s", b0Var4.f21184e);
} catch (Exception e2) {
b0.this.p(e2);
System.err.println("Error binding monitor port " + b0.this.f21181b + ": " + e2.toString());
b0.this.f21184e = null;
b0 b0Var5 = b0.this;
b0Var5.o("STOP.PORT=%d", Integer.valueOf(b0Var5.f21181b));
b0 b0Var6 = b0.this;
b0Var6.o("STOP.KEY=%s", b0Var6.f21182c);
b0 b0Var7 = b0.this;
b0Var7.o("%s", b0Var7.f21184e);
}
} catch (Throwable th) {
b0 b0Var8 = b0.this;
b0Var8.o("STOP.PORT=%d", Integer.valueOf(b0Var8.f21181b));
b0 b0Var9 = b0.this;
b0Var9.o("STOP.KEY=%s", b0Var9.f21182c);
b0 b0Var10 = b0.this;
b0Var10.o("%s", b0Var10.f21184e);
throw th;
}
}
@Override
public void run() {
Socket socket;
Throwable th;
Exception e2;
LineNumberReader lineNumberReader;
if (b0.this.f21184e == null) {
return;
}
while (b0.this.f21184e != null) {
Socket socket2 = null;
try {
socket = b0.this.f21184e.accept();
try {
try {
lineNumberReader = new LineNumberReader(new InputStreamReader(socket.getInputStream()));
} catch (Throwable th2) {
th = th2;
b0.this.n(socket);
throw th;
}
} catch (Exception e3) {
e2 = e3;
b0.this.p(e2);
System.err.println(e2.toString());
b0.this.n(socket);
}
} catch (Exception e4) {
socket = null;
e2 = e4;
} catch (Throwable th3) {
socket = null;
th = th3;
}
if (!b0.this.f21182c.equals(lineNumberReader.readLine())) {
System.err.println("Ignoring command with incorrect key");
b0.this.n(socket);
} else {
OutputStream outputStream = socket.getOutputStream();
String readLine = lineNumberReader.readLine();
b0.this.o("command=%s", readLine);
if ("stop".equals(readLine)) {
b0.this.o("Issuing graceful shutdown..", new Object[0]);
n.b.a.h.q0.c.b().run();
b0.this.o("Informing client that we are stopped.", new Object[0]);
outputStream.write("Stopped\r\n".getBytes("UTF-8"));
outputStream.flush();
b0.this.o("Shutting down monitor", new Object[0]);
b0.this.n(socket);
b0 b0Var = b0.this;
b0Var.m(b0Var.f21184e);
b0.this.f21184e = null;
if (b0.this.f21183d) {
b0.this.o("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;
}
b0.this.n(socket2);
}
}
}
@Override
public void start() {
if (isAlive()) {
System.err.printf("ShutdownMonitorThread already started", new Object[0]);
return;
}
a();
if (b0.this.f21184e == null) {
return;
}
if (b0.this.f21180a) {
System.err.println("Starting ShutdownMonitorThread");
}
super.start();
}
}
public void m(ServerSocket serverSocket) {
if (serverSocket == null) {
return;
}
try {
serverSocket.close();
} catch (IOException unused) {
}
}
public void n(Socket socket) {
if (socket == null) {
return;
}
try {
socket.close();
} catch (IOException unused) {
}
}
public void o(String str, Object... objArr) {
if (this.f21180a) {
System.err.printf("[ShutdownMonitor] " + str + "%n", objArr);
}
}
public void p(Throwable th) {
if (this.f21180a) {
th.printStackTrace(System.err);
}
}
public static b0 q() {
return b.f21186a;
}
public void A() throws Exception {
synchronized (this) {
c cVar = this.f21185f;
if (cVar != null && cVar.isAlive()) {
System.err.printf("ShutdownMonitorThread already started", new Object[0]);
return;
}
c cVar2 = new c();
this.f21185f = cVar2;
if (cVar2 != null) {
cVar2.start();
}
}
}
public String r() {
return this.f21182c;
}
public int s() {
return this.f21181b;
}
public ServerSocket t() {
return this.f21184e;
}
public String toString() {
return String.format("%s[port=%d]", getClass().getName(), Integer.valueOf(this.f21181b));
}
public boolean u() {
boolean z;
synchronized (this) {
c cVar = this.f21185f;
z = cVar != null && cVar.isAlive();
}
return z;
}
public boolean v() {
return this.f21183d;
}
public void w(boolean z) {
this.f21180a = z;
}
public void x(boolean z) {
synchronized (this) {
c cVar = this.f21185f;
if (cVar != null && cVar.isAlive()) {
throw new IllegalStateException("ShutdownMonitorThread already started");
}
this.f21183d = z;
}
}
public void y(String str) {
synchronized (this) {
c cVar = this.f21185f;
if (cVar != null && cVar.isAlive()) {
throw new IllegalStateException("ShutdownMonitorThread already started");
}
this.f21182c = str;
}
}
public void z(int i2) {
synchronized (this) {
c cVar = this.f21185f;
if (cVar != null && cVar.isAlive()) {
throw new IllegalStateException("ShutdownMonitorThread already started");
}
this.f21181b = i2;
}
}
private b0() {
Properties properties = System.getProperties();
this.f21180a = properties.containsKey("DEBUG");
this.f21181b = Integer.parseInt(properties.getProperty("STOP.PORT", "-1"));
this.f21182c = properties.getProperty("STOP.KEY", null);
this.f21183d = true;
}
}