-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns resolver configurable from outside via WebserviceConfiguration (#30)
- Loading branch information
Showing
7 changed files
with
72 additions
and
31 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/cz/tomasdvorak/eet/client/dto/DnsResolver.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,20 @@ | ||
package cz.tomasdvorak.eet.client.dto; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
/** | ||
* Implement this interface if you want to use dns lookup different than default implementation based on {@link InetAddress}. | ||
* You can for example use http://www.xbill.org/dnsjava/ implementation or any other custom logic. | ||
*/ | ||
public interface DnsResolver { | ||
|
||
/** | ||
* Convert a domain name to IP address. | ||
* | ||
* @param hostname Pure hostname, without protocol or path. For example pg.eet.cz | ||
* @return IP address as a String | ||
* @throws UnknownHostException in case DNS lookup fails. | ||
*/ | ||
String getHostAddress(String hostname) throws UnknownHostException; | ||
} |
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
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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/cz/tomasdvorak/eet/client/networking/InetAddressDnsResolver.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,15 @@ | ||
package cz.tomasdvorak.eet.client.networking; | ||
|
||
import cz.tomasdvorak.eet.client.dto.DnsResolver; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
public class InetAddressDnsResolver implements DnsResolver { | ||
|
||
@Override | ||
public String getHostAddress(final String hostname) throws UnknownHostException { | ||
InetAddress address = InetAddress.getByName(hostname); | ||
return address.getHostAddress(); | ||
} | ||
} |
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
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