正在查看: 小柿子 v1.3.8 应用的 w.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 小柿子 v1.3.8 应用的 w.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package o5;
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 w {
public boolean a;
public int b;
public String c;
public boolean d;
public ServerSocket e;
public c f;
public static class b {
public static w a = new w();
}
public class c extends Thread {
public c() {
setDaemon(true);
setName("ShutdownMonitor");
}
public final void a() {
if (w.this.b < 0) {
if (w.this.a) {
System.err.println("ShutdownMonitor not in use (port < 0): " + w.this.b);
return;
}
return;
}
try {
try {
w.this.e = new ServerSocket(w.this.b, 1, InetAddress.getByName("127.0.0.1"));
if (w.this.b == 0) {
w wVar = w.this;
wVar.b = wVar.e.getLocalPort();
System.out.printf("STOP.PORT=%d%n", Integer.valueOf(w.this.b));
}
if (w.this.c == null) {
w.this.c = Long.toString((long) ((Math.random() * 9.223372036854776E18d) + hashCode() + System.currentTimeMillis()), 36);
System.out.printf("STOP.KEY=%s%n", w.this.c);
}
w wVar2 = w.this;
wVar2.o("STOP.PORT=%d", Integer.valueOf(wVar2.b));
w wVar3 = w.this;
wVar3.o("STOP.KEY=%s", wVar3.c);
w wVar4 = w.this;
wVar4.o("%s", wVar4.e);
} catch (Exception e) {
w.this.p(e);
System.err.println("Error binding monitor port " + w.this.b + ": " + e.toString());
w.this.e = null;
w wVar5 = w.this;
wVar5.o("STOP.PORT=%d", Integer.valueOf(wVar5.b));
w wVar6 = w.this;
wVar6.o("STOP.KEY=%s", wVar6.c);
w wVar7 = w.this;
wVar7.o("%s", wVar7.e);
}
} catch (Throwable th) {
w wVar8 = w.this;
wVar8.o("STOP.PORT=%d", Integer.valueOf(wVar8.b));
w wVar9 = w.this;
wVar9.o("STOP.KEY=%s", wVar9.c);
w wVar10 = w.this;
wVar10.o("%s", wVar10.e);
throw th;
}
}
@Override
public void run() {
Socket socket;
Throwable th;
Exception e;
LineNumberReader lineNumberReader;
if (w.this.e == null) {
return;
}
while (w.this.e != null) {
Socket socket2 = null;
try {
socket = w.this.e.accept();
try {
try {
lineNumberReader = new LineNumberReader(new InputStreamReader(socket.getInputStream()));
} catch (Throwable th2) {
th = th2;
w.this.n(socket);
throw th;
}
} catch (Exception e2) {
e = e2;
w.this.p(e);
System.err.println(e.toString());
w.this.n(socket);
}
} catch (Exception e3) {
socket = null;
e = e3;
} catch (Throwable th3) {
socket = null;
th = th3;
}
if (w.this.c.equals(lineNumberReader.readLine())) {
OutputStream outputStream = socket.getOutputStream();
String readLine = lineNumberReader.readLine();
w.this.o("command=%s", readLine);
if ("stop".equals(readLine)) {
w.this.o("Issuing graceful shutdown..", new Object[0]);
y5.c.b().run();
w.this.o("Informing client that we are stopped.", new Object[0]);
outputStream.write("Stopped\r\n".getBytes("UTF-8"));
outputStream.flush();
w.this.o("Shutting down monitor", new Object[0]);
w.this.n(socket);
w wVar = w.this;
wVar.m(wVar.e);
w.this.e = null;
if (w.this.d) {
w.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;
}
w.this.n(socket2);
} else {
System.err.println("Ignoring command with incorrect key");
w.this.n(socket);
}
}
}
@Override
public void start() {
if (isAlive()) {
System.err.printf("ShutdownMonitorThread already started", new Object[0]);
return;
}
a();
if (w.this.e == null) {
return;
}
if (w.this.a) {
System.err.println("Starting ShutdownMonitorThread");
}
super.start();
}
}
public static w q() {
return b.a;
}
public final void m(ServerSocket serverSocket) {
if (serverSocket == null) {
return;
}
try {
serverSocket.close();
} catch (IOException unused) {
}
}
public final void n(Socket socket) {
if (socket == null) {
return;
}
try {
socket.close();
} catch (IOException unused) {
}
}
public final void o(String str, Object... objArr) {
if (this.a) {
System.err.printf("[ShutdownMonitor] " + str + "%n", objArr);
}
}
public final void p(Throwable th) {
if (this.a) {
th.printStackTrace(System.err);
}
}
public void r() throws Exception {
synchronized (this) {
c cVar = this.f;
if (cVar != null && cVar.isAlive()) {
System.err.printf("ShutdownMonitorThread already started", new Object[0]);
return;
}
c cVar2 = new c();
this.f = cVar2;
cVar2.start();
}
}
public String toString() {
return String.format("%s[port=%d]", getClass().getName(), Integer.valueOf(this.b));
}
public w() {
Properties properties = System.getProperties();
this.a = properties.containsKey("DEBUG");
this.b = Integer.parseInt(properties.getProperty("STOP.PORT", "-1"));
this.c = properties.getProperty("STOP.KEY", null);
this.d = true;
}
}