mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Allow direct download templates from IPv6 host address. (#5900)
* Allow templates & ISOs from IPv6 host address. * fix checkstyle issue * Allow only direct download templates from IPv6 address Co-authored-by: gabriel <gabriel@apache.org>
This commit is contained in:
parent
6fa8538666
commit
0e150954d0
@ -216,7 +216,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||||||
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
|
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
|
||||||
TemplateProfile profile = super.prepare(cmd);
|
TemplateProfile profile = super.prepare(cmd);
|
||||||
String url = profile.getUrl();
|
String url = profile.getUrl();
|
||||||
UriUtils.validateUrl(cmd.getFormat(), url);
|
UriUtils.validateUrl(cmd.getFormat(), url, cmd.isDirectDownload());
|
||||||
if (cmd.isDirectDownload()) {
|
if (cmd.isDirectDownload()) {
|
||||||
DigestHelper.validateChecksumString(cmd.getChecksum());
|
DigestHelper.validateChecksumString(cmd.getChecksum());
|
||||||
Long templateSize = performDirectDownloadUrlValidation(cmd.getFormat(), url, cmd.getZoneIds());
|
Long templateSize = performDirectDownloadUrlValidation(cmd.getFormat(), url, cmd.getZoneIds());
|
||||||
|
|||||||
@ -263,6 +263,10 @@ public class UriUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<String, Integer> validateUrl(String format, String url) throws IllegalArgumentException {
|
public static Pair<String, Integer> validateUrl(String format, String url) throws IllegalArgumentException {
|
||||||
|
return validateUrl(format, url, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pair<String, Integer> validateUrl(String format, String url, boolean skipIpv6Check) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
URI uri = new URI(url);
|
URI uri = new URI(url);
|
||||||
if ((uri.getScheme() == null) ||
|
if ((uri.getScheme() == null) ||
|
||||||
@ -283,7 +287,7 @@ public class UriUtils {
|
|||||||
if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
|
if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
|
||||||
throw new IllegalArgumentException("Illegal host specified in url");
|
throw new IllegalArgumentException("Illegal host specified in url");
|
||||||
}
|
}
|
||||||
if (hostAddr instanceof Inet6Address) {
|
if (!skipIpv6Check && hostAddr instanceof Inet6Address) {
|
||||||
throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
|
throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException uhe) {
|
} catch (UnknownHostException uhe) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user