Skip to content

Commit

Permalink
Merge pull request #14828 from iterate-ch/bugfix/MD-19401
Browse files Browse the repository at this point in the history
Run through hostname configurator prior trying to resolve address.
  • Loading branch information
dkocher authored Jun 20, 2023
2 parents d57b7d9 + 93298d7 commit b837fc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ch.cyberduck.binding.foundation.NSNotificationCenter;
import ch.cyberduck.binding.foundation.NSObject;
import ch.cyberduck.core.Host;
import ch.cyberduck.core.HostnameConfiguratorFactory;
import ch.cyberduck.core.idna.PunycodeConverter;

import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -97,11 +98,11 @@ public boolean isReachable(final Host bookmark) {
return false;
}

protected static String toURL(final Host host) {
StringBuilder url = new StringBuilder(host.getProtocol().getScheme().toString());
protected static String toURL(final Host bookmark) {
StringBuilder url = new StringBuilder(bookmark.getProtocol().getScheme().toString());
url.append("://");
url.append(new PunycodeConverter().convert(host.getHostname()));
url.append(":").append(host.getPort());
url.append(new PunycodeConverter().convert(HostnameConfiguratorFactory.get(bookmark.getProtocol()).getHostname(bookmark.getHostname())));
url.append(":").append(bookmark.getPort());
return url.toString();
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/ch/cyberduck/core/HostUrlProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String get(final Host bookmark) {
final Scheme scheme = bookmark.getProtocol().getScheme();
final int port = bookmark.getPort();
final String username = bookmark.getCredentials().getUsername();
final String hostname = bookmark.getHostname();
final String hostname = HostnameConfiguratorFactory.get(bookmark.getProtocol()).getHostname(bookmark.getHostname());
final String path = bookmark.getDefaultPath();
return this.get(scheme, port, username, hostname, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import ch.cyberduck.core.ConnectionTimeoutFactory;
import ch.cyberduck.core.Host;
import ch.cyberduck.core.HostnameConfiguratorFactory;

import java.io.IOException;
import java.net.InetAddress;
Expand All @@ -30,10 +31,10 @@
public class DefaultInetAddressReachability extends DisabledReachability {

@Override
public boolean isReachable(final Host host) {
public boolean isReachable(final Host bookmark) {
try {
return InetAddress.getByName(host.getHostname()).isReachable(
ConnectionTimeoutFactory.get(host).getTimeout() * 1000
return InetAddress.getByName(HostnameConfiguratorFactory.get(bookmark.getProtocol()).getHostname(bookmark.getHostname())).isReachable(
ConnectionTimeoutFactory.get(bookmark).getTimeout() * 1000
);
}
catch(IOException e) {
Expand Down

0 comments on commit b837fc9

Please sign in to comment.