Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
_consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT);
}

value = configs.get("consoleproxy.sslEnabled");
value = configs.get(ConsoleProxySslEnabled.key());
if (value != null && value.equalsIgnoreCase("true")) {
_sslEnabled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd) {
byte[] ksBits = null;

String consoleProxyUrlDomain = _configDao.getValue(Config.ConsoleProxyUrlDomain.key());
String consoleProxySslEnabled = _configDao.getValue("consoleproxy.sslEnabled");
String consoleProxySslEnabled = _configDao.getValue(ConsoleProxyManager.ConsoleProxySslEnabled.key());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String consoleProxySslEnabled = _configDao.getValue(ConsoleProxyManager.ConsoleProxySslEnabled.key());
String consoleProxySslEnabled = ConsoleProxyManager.ConsoleProxySslEnabled.value();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GutoVeronezi
this may not work as the _configDao is set in the constructor of the class.

    protected AgentHookBase(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao, KeystoreManager ksMgr,
                         AgentManager agentMgr, KeysManager keysMgr, ConsoleAccessManager consoleAccessMgr) {
        _instanceDao = instanceDao;
        _hostDao = hostDao;
        _agentMgr = agentMgr;
        _configDao = cfgDao;
        _ksMgr = ksMgr;
        _keysMgr = keysMgr;
        consoleAccessManager = consoleAccessMgr;
    }

@GutoVeronezi GutoVeronezi Mar 20, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the class will have access to the DB, it should work, as the value() will query for the value (if the configDepot is configured).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some debugging, it looks the values are the same.

2024-03-21T08:05:48,498 DEBUG [c.c.c.ConsoleProxyManagerImpl] (main:[]) (logid:) configs.get(ConsoleProxySslEnabled.key() = true
2024-03-21T08:05:48,502 DEBUG [c.c.c.ConsoleProxyManagerImpl] (main:[]) (logid:) ConsoleProxySslEnabled.value() = true

2024-03-21T08:06:02,499 DEBUG [c.c.c.C.VmBasedAgentHook] (AgentConnectTaskPool-4:[ctx-f64d74cc]) (logid:29169184) _configDao.getValue(ConsoleProxyManager.ConsoleProxySslEnabled.key()) = true
2024-03-21T08:06:02,499 DEBUG [c.c.c.C.VmBasedAgentHook] (AgentConnectTaskPool-4:[ctx-f64d74cc]) (logid:29169184) ConsoleProxySslEnabled.value() = true

however, I prefer not to change the code as the old/new codes basically get the same value from database.
The old code has been proved to be working. Some other values are fetched in the same way.
@GutoVeronezi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as line-215

if (!StringUtils.isEmpty(consoleProxyUrlDomain) && !StringUtils.isEmpty(consoleProxySslEnabled)
&& consoleProxySslEnabled.equalsIgnoreCase("true")) {
ksBits = _ksMgr.getKeystoreBits(ConsoleProxyManager.CERTIFICATE_NAME, ConsoleProxyManager.CERTIFICATE_NAME, storePassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
String ALERT_SUBJECT = "proxy-alert";
String CERTIFICATE_NAME = "CPVMCertificate";

ConfigKey<Boolean> ConsoleProxySslEnabled = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "consoleproxy.sslEnabled", "false",
Comment thread
weizhouapache marked this conversation as resolved.
"Enable SSL for console proxy", false);

ConfigKey<Boolean> NoVncConsoleDefault = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "novnc.console.default", "true",
"If true, noVNC console will be default console for virtual machines", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu

Map<String, String> configs = configurationDao.getConfiguration("management-server", params);

String value = configs.get("consoleproxy.sslEnabled");
String value = configs.get(ConsoleProxySslEnabled.key());
if (value != null && value.equalsIgnoreCase("true")) {
sslEnabled = true;
}
Expand Down Expand Up @@ -1609,7 +1609,7 @@ public String getConfigComponentName() {

@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] { NoVncConsoleDefault, NoVncConsoleSourceIpCheckEnabled };
return new ConfigKey<?>[] { ConsoleProxySslEnabled, NoVncConsoleDefault, NoVncConsoleSourceIpCheckEnabled };
}

protected ConsoleProxyStatus parseJsonToConsoleProxyStatus(String json) throws JsonParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
_ip = "127.0.0.1";
}

String value = (String)params.get("consoleproxy.sslEnabled");
String value = (String)params.get(ConsoleProxySslEnabled.key());
if (value != null && value.equalsIgnoreCase("true")) {
_sslEnabled = true;
}
Expand Down