rafaelweingartner commented on a change in pull request #2734: Fix invalid
consoleproxy url after upgrade
URL: https://github.com/apache/cloudstack/pull/2734#discussion_r202344815
##########
File path: core/src/com/cloud/info/ConsoleProxyInfo.java
##########
@@ -35,38 +35,40 @@ public ConsoleProxyInfo(int proxyUrlPort) {
public ConsoleProxyInfo(boolean sslEnabled, String proxyIpAddress, int
port, int proxyUrlPort, String consoleProxyUrlDomain) {
this.sslEnabled = sslEnabled;
+ this.proxyPort = port;
+ this.proxyUrlPort = proxyUrlPort;
+ this.proxyAddress = this.formatProxyAddress(consoleProxyUrlDomain,
proxyIpAddress);
if (sslEnabled) {
- StringBuffer sb = new StringBuffer();
- if (consoleProxyUrlDomain.startsWith("*")) {
- sb.append(proxyIpAddress);
- for (int i = 0; i < proxyIpAddress.length(); i++)
- if (sb.charAt(i) == '.')
- sb.setCharAt(i, '-');
- sb.append(consoleProxyUrlDomain.substring(1));//skip the *
- } else {
- //LB address
- sb.append(consoleProxyUrlDomain);
- }
- proxyAddress = sb.toString();
- proxyPort = port;
- this.proxyUrlPort = proxyUrlPort;
-
proxyImageUrl = "https://" + proxyAddress;
- if (proxyUrlPort != 443)
+ if (proxyUrlPort != 443) {
proxyImageUrl += ":" + this.proxyUrlPort;
- } else {
- proxyAddress = proxyIpAddress;
- if (StringUtils.isNotBlank(consoleProxyUrlDomain)) {
- proxyAddress = consoleProxyUrlDomain;
}
- proxyPort = port;
- this.proxyUrlPort = proxyUrlPort;
+ } else {
proxyImageUrl = "http://" + proxyAddress;
- if (proxyUrlPort != 80)
+ if (proxyUrlPort != 80) {
proxyImageUrl += ":" + proxyUrlPort;
+ }
+ }
+ }
+
+ private String formatProxyAddress(String consoleProxyUrlDomain, String
proxyIpAddress) {
Review comment:
@resmo you already did a lot! I would like to see a documentation (instead
of inline comments) and unit tests for this method though.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services