-
-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Register custom DNS resolver to handle IPv6 preference.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
core/src/main/java/ch/cyberduck/core/http/CustomDnsResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters