-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- cancel ongoing requests just after reception of the response first arrived - handles all the exception thrown during DNS resolution by returning DnsRecord object
- Loading branch information
Showing
4 changed files
with
85 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.doodream.robustdns; | ||
|
||
import java.net.InetAddress; | ||
|
||
public class DnsRecord { | ||
private static final DnsRecord FAIL = new DnsRecord(); | ||
boolean isSuccessful; | ||
InetAddress address; | ||
long expireAt; | ||
|
||
public static DnsRecord fail() { | ||
return FAIL; | ||
} | ||
|
||
public static DnsRecord success(InetAddress resolved, long expireAt) { | ||
return new DnsRecord(resolved, expireAt); | ||
} | ||
|
||
private DnsRecord() { | ||
isSuccessful = false; | ||
} | ||
|
||
private DnsRecord(InetAddress resolved, long expireAt) { | ||
isSuccessful = true; | ||
address = resolved; | ||
this.expireAt = expireAt; | ||
} | ||
|
||
public boolean isSuccessful() { | ||
return isSuccessful; | ||
} | ||
|
||
public InetAddress getAddress() { | ||
return address; | ||
} | ||
} |
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