Skip to content

Commit

Permalink
Merge pull request #13399 from iterate-ch/bugfix/GH-12917-httpcomponents
Browse files Browse the repository at this point in the history
Register custom DNS resolver to handle IPv6 preference.
  • Loading branch information
dkocher authored May 17, 2022
2 parents d6836f6 + bde2bcb commit 996742d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions core/src/main/java/ch/cyberduck/core/http/CustomDnsResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.cyberduck.core.http;

/*
* Copyright (c) 2002-2022 iterate GmbH. All rights reserved.
* https://cyberduck.io/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

import ch.cyberduck.core.DisabledCancelCallback;
import ch.cyberduck.core.Resolver;
import ch.cyberduck.core.exception.ResolveCanceledException;
import ch.cyberduck.core.exception.ResolveFailedException;
import org.apache.http.conn.DnsResolver;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class CustomDnsResolver implements DnsResolver {

private final Resolver resolver = new Resolver();

@Override
public InetAddress[] resolve(String host) throws UnknownHostException {
try {
return new InetAddress[]{resolver.resolve(host, new DisabledCancelCallback())};
}
catch(ResolveFailedException | ResolveCanceledException e) {
throw new UnknownHostException(e.getDetail(false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public HttpClientBuilder build(final Proxy proxy, final TranscriptListener liste
new BackportWindowsNegotiateSchemeFactory(null) :
new SPNegoSchemeFactory())
.register(AuthSchemes.KERBEROS, new KerberosSchemeFactory()).build());
configuration.setDnsResolver(new CustomDnsResolver());
return configuration;
}

Expand Down

0 comments on commit 996742d

Please sign in to comment.