Skip to content

Commit bbacd58

Browse files
committed
utils: UriUtils.validateUrl() shouldn't care if a host resolves to an IPv6 address
This is leftover code from a long time ago and this validation test has nu influence on the end result on how a URL will be used afterwards. We should support hosts pointing to an IPv6(-only) address out of the box. For the code it does not matter if it's IPv4 or IPv6. This is the admin's choice.
1 parent 9d51d03 commit bbacd58

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public TemplateProfile prepare(GetUploadParamsForIsoCmd cmd) throws ResourceAllo
234234
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
235235
TemplateProfile profile = super.prepare(cmd);
236236
String url = profile.getUrl();
237-
UriUtils.validateUrl(cmd.getFormat(), url, cmd.isDirectDownload());
237+
UriUtils.validateUrl(cmd.getFormat(), url);
238238
Hypervisor.HypervisorType hypervisor = Hypervisor.HypervisorType.getType(cmd.getHypervisor());
239239
if (cmd.isDirectDownload()) {
240240
DigestHelper.validateChecksumString(cmd.getChecksum());

utils/src/main/java/com/cloud/utils/UriUtils.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.io.IOException;
2424
import java.io.InputStream;
2525
import java.net.HttpURLConnection;
26-
import java.net.Inet6Address;
2726
import java.net.InetAddress;
2827
import java.net.URI;
2928
import java.net.URISyntaxException;
@@ -261,10 +260,6 @@ public static Pair<String, Integer> validateUrl(String url) throws IllegalArgume
261260
}
262261

263262
public static Pair<String, Integer> validateUrl(String format, String url) throws IllegalArgumentException {
264-
return validateUrl(format, url, false);
265-
}
266-
267-
public static Pair<String, Integer> validateUrl(String format, String url, boolean skipIpv6Check) throws IllegalArgumentException {
268263
try {
269264
URI uri = new URI(url);
270265
if ((uri.getScheme() == null) ||
@@ -285,9 +280,6 @@ public static Pair<String, Integer> validateUrl(String format, String url, boole
285280
if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
286281
throw new IllegalArgumentException("Illegal host specified in url");
287282
}
288-
if (!skipIpv6Check && hostAddr instanceof Inet6Address) {
289-
throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
290-
}
291283
} catch (UnknownHostException uhe) {
292284
throw new IllegalArgumentException("Unable to resolve " + host);
293285
}

0 commit comments

Comments
 (0)