mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Remove the dependency on VNC port for session management inside Console Proxy. This is to adapt Xen secure console support
This commit is contained in:
parent
6c9fd606ab
commit
2b6666ccd1
@ -397,8 +397,7 @@ public class ConsoleProxy {
|
||||
s_logger.info("Added viewer object " + viewer);
|
||||
reportLoadChange = true;
|
||||
} else if (!viewer.isFrontEndAlive()) {
|
||||
s_logger.info("The rfb thread died, reinitializing the viewer " +
|
||||
viewer);
|
||||
s_logger.info("The rfb thread died, reinitializing the viewer " + viewer);
|
||||
viewer.initClient(param);
|
||||
} else if (!param.getClientHostPassword().equals(viewer.getClientHostPassword())) {
|
||||
s_logger.warn("Bad sid detected(VNC port may be reused). sid in session: "
|
||||
|
||||
@ -43,12 +43,16 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
protected Object tileDirtyEvent = new Object();
|
||||
protected TileTracker tracker;
|
||||
protected AjaxFIFOImageCache ajaxImageCache = new AjaxFIFOImageCache(2);
|
||||
|
||||
|
||||
/*
|
||||
protected String host;
|
||||
protected int port;
|
||||
protected String passwordParam;
|
||||
protected String tag = "";
|
||||
protected String ticket = "";
|
||||
protected String ticket = "";
|
||||
*/
|
||||
protected ConsoleProxyClientParam clientParam;
|
||||
|
||||
protected long createTime = System.currentTimeMillis();
|
||||
protected long lastFrontEndActivityTime = System.currentTimeMillis();
|
||||
|
||||
@ -105,22 +109,24 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
|
||||
@Override
|
||||
public String getClientHostAddress() {
|
||||
return host;
|
||||
return clientParam.getClientHostAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClientHostPort() {
|
||||
return port;
|
||||
return clientParam.getClientHostPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientHostPassword() {
|
||||
return passwordParam;
|
||||
return clientParam.getClientHostPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientTag() {
|
||||
return tag;
|
||||
public String getClientTag() {
|
||||
if(clientParam.getClientTag() != null)
|
||||
return clientParam.getClientTag();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,9 +194,10 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
|
||||
int key = ajaxImageCache.putImage(imgBits);
|
||||
StringBuffer sb = new StringBuffer("/ajaximg?host=");
|
||||
sb.append(host).append("&port=").append(port).append("&sid=").append(passwordParam);
|
||||
sb.append("&key=").append(key).append("&ts=").append(System.currentTimeMillis());
|
||||
return sb.toString();
|
||||
sb.append(getClientHostAddress()).append("&port=").append(getClientHostPort()).append("&sid=").append(getClientHostPassword());
|
||||
sb.append("&key=").append(key).append("&tag=").append(this.getClientTag());
|
||||
sb.append("&ts=").append(System.currentTimeMillis());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String prepareAjaxSession(boolean init) {
|
||||
@ -202,8 +209,8 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append("/ajax?host=").append(host).append("&port=").append(port);
|
||||
sb.append("&sid=").append(passwordParam).append("&sess=").append(ajaxSessionId);
|
||||
sb.append("/ajax?host=").append(getClientHostAddress()).append("&port=").append(getClientHostPort());
|
||||
sb.append("&sid=").append(getClientHostPassword()).append("&tag=").append(getClientTag()).append("&sess=").append(ajaxSessionId);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -440,5 +447,13 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
lastFrontEndActivityTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
protected abstract FrameBufferCanvas getFrameBufferCavas();
|
||||
protected abstract FrameBufferCanvas getFrameBufferCavas();
|
||||
|
||||
public ConsoleProxyClientParam getClientParam() {
|
||||
return clientParam;
|
||||
}
|
||||
|
||||
public void setClientParam(ConsoleProxyClientParam clientParam) {
|
||||
this.clientParam = clientParam;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +89,9 @@ public class ConsoleProxyClientParam {
|
||||
}
|
||||
|
||||
public String getClientMapKey() {
|
||||
if(clientTag != null && !clientTag.isEmpty())
|
||||
return clientTag;
|
||||
|
||||
return clientHostAddress + ":" + clientHostPort;
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,8 +64,9 @@ public class ConsoleProxyGCThread extends Thread {
|
||||
while (true) {
|
||||
cleanupLogging();
|
||||
bReportLoad = false;
|
||||
|
||||
s_logger.info("connMap=" + connMap);
|
||||
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("connMap=" + connMap);
|
||||
Enumeration<String> e = connMap.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
String key;
|
||||
@ -98,7 +99,7 @@ public class ConsoleProxyGCThread extends Thread {
|
||||
s_logger.debug("Report load change : " + loadInfo);
|
||||
}
|
||||
|
||||
try { Thread.sleep(1000); } catch (InterruptedException ex) {}
|
||||
try { Thread.sleep(5000); } catch (InterruptedException ex) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +130,9 @@ public class ConsoleProxyThumbnailHandler implements HttpHandler {
|
||||
param.setClientHostPassword(sid);
|
||||
param.setClientTag(tag);
|
||||
param.setTicket(ticket);
|
||||
param.setClientTunnelUrl(console_url);
|
||||
param.setClientTunnelSession(console_host_session);
|
||||
|
||||
ConsoleProxyClient viewer = ConsoleProxy.getVncViewer(param);
|
||||
|
||||
if (!viewer.isHostConnected()) {
|
||||
|
||||
@ -54,12 +54,8 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initClient(ConsoleProxyClientParam param) {
|
||||
this.host = param.getClientHostAddress();
|
||||
this.port = param.getClientHostPort();
|
||||
this.passwordParam = param.getClientHostPassword();
|
||||
this.tag = param.getClientTag();
|
||||
this.ticket = param.getTicket();
|
||||
public void initClient(ConsoleProxyClientParam param) {
|
||||
setClientParam(param);
|
||||
|
||||
final String tunnelUrl = param.getClientTunnelUrl();
|
||||
final String tunnelSession = param.getClientTunnelSession();
|
||||
@ -78,13 +74,13 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase {
|
||||
uri.getHost(), uri.getPort(),
|
||||
uri.getPath() + "?" + uri.getQuery(),
|
||||
tunnelSession, "https".equalsIgnoreCase(uri.getScheme()),
|
||||
passwordParam);
|
||||
getClientHostPassword());
|
||||
} catch (URISyntaxException e) {
|
||||
s_logger.warn("Invalid tunnel URL " + tunnelUrl);
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Connect to VNC server directly. host: " + host + ", port: " + port);
|
||||
client.connectTo(host, port, passwordParam);
|
||||
s_logger.info("Connect to VNC server directly. host: " + getClientHostAddress() + ", port: " + getClientHostPort());
|
||||
client.connectTo(getClientHostAddress(), getClientHostPort(), getClientHostPassword());
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
s_logger.error("Unexpected exception: ", e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user