mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-3456: proactively close XAPI initiated console session from console proxy to avoid DoS behave to XS host
This commit is contained in:
parent
c301734e22
commit
0cf3b75c2f
|
|
@ -64,6 +64,7 @@ public class ConsoleProxyGCThread extends Thread {
|
|||
public void run() {
|
||||
|
||||
boolean bReportLoad = false;
|
||||
long lastReportTick = System.currentTimeMillis();
|
||||
while (true) {
|
||||
cleanupLogging();
|
||||
bReportLoad = false;
|
||||
|
|
@ -95,10 +96,12 @@ public class ConsoleProxyGCThread extends Thread {
|
|||
client.closeClient();
|
||||
}
|
||||
|
||||
if(bReportLoad) {
|
||||
if(bReportLoad || System.currentTimeMillis() - lastReportTick > 5000) {
|
||||
// report load changes
|
||||
String loadInfo = new ConsoleProxyClientStatsCollector(connMap).getStatsReport();
|
||||
ConsoleProxy.reportLoadInfo(loadInfo);
|
||||
lastReportTick = System.currentTimeMillis();
|
||||
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Report load change : " + loadInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
|
|||
|
||||
private VncClient client;
|
||||
private Thread worker;
|
||||
private boolean workerDone = false;
|
||||
private volatile boolean workerDone = false;
|
||||
|
||||
private int lastModifierStates = 0;
|
||||
private int lastPointerMask = 0;
|
||||
|
|
@ -80,7 +80,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
|
|||
String tunnelUrl = getClientParam().getClientTunnelUrl();
|
||||
String tunnelSession = getClientParam().getClientTunnelSession();
|
||||
|
||||
for(int i = 0; i < 15; i++) {
|
||||
for(int i = 0; i < 15 && !workerDone; i++) {
|
||||
try {
|
||||
if(tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) {
|
||||
URI uri = new URI(tunnelUrl);
|
||||
|
|
@ -136,6 +136,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
|
|||
|
||||
@Override
|
||||
public void closeClient() {
|
||||
workerDone = true;
|
||||
if(client != null)
|
||||
client.shutdown();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,8 +77,10 @@ public class VncClientPacketSender implements Runnable, PaintNotificationListene
|
|||
s_logger.error("Unexpected exception: ", e);
|
||||
if (connectionAlive) {
|
||||
closeConnection();
|
||||
vncConnection.shutdown();
|
||||
}
|
||||
} finally {
|
||||
s_logger.info("Sending thread exit processing, shutdown connection");
|
||||
vncConnection.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,8 +90,10 @@ public class VncServerPacketReceiver implements Runnable {
|
|||
s_logger.error("Unexpected exception: ", e);
|
||||
if (connectionAlive) {
|
||||
closeConnection();
|
||||
vncConnection.shutdown();
|
||||
}
|
||||
} finally {
|
||||
s_logger.info("Receiving thread exit processing, shutdown connection");
|
||||
vncConnection.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue