generated from mingliqiye/lib-tem
Compare commits
No commits in common. "f645ffacdff76d8f25c42021ee3ad521a42cfd70" and "133fd1a77d4beefa1959fb7ac515314aa0386054" have entirely different histories.
f645ffacdf
...
133fd1a77d
@ -1,5 +1,5 @@
|
||||
GROUPSID=com.mingliqiye
|
||||
ARTIFACTID=network-endpoint
|
||||
VERSIONS=1.0.3
|
||||
VERSIONS=1.0.2
|
||||
MAINCLASS=com.mingliqiye
|
||||
JDKVERSIONS=1.8
|
||||
|
@ -56,14 +56,12 @@ public class NetworkAddress implements Serializable {
|
||||
public static NetworkAddress of(String domip) {
|
||||
return new NetworkAddress(domip);
|
||||
}
|
||||
|
||||
public static NetworkAddress of(InetAddress inetAddress) {
|
||||
return new NetworkAddress(inetAddress.getHostAddress());
|
||||
}
|
||||
|
||||
public InetAddress toInetAddress() {
|
||||
public InetAddress toInetAddress(){
|
||||
try {
|
||||
return InetAddress.getByName(ip != null ? ip : domain);
|
||||
return InetAddress.getByName(domain);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -76,8 +74,7 @@ public class NetworkAddress implements Serializable {
|
||||
* @return IP地址
|
||||
* @throws UnknownHostException 没找到对应的IP
|
||||
*/
|
||||
public static String getHostIp(@NotNull String domain)
|
||||
throws UnknownHostException {
|
||||
public static String getHostIp(@NotNull String domain) throws UnknownHostException {
|
||||
InetAddress[] addresses = InetAddress.getAllByName(domain.trim());
|
||||
return addresses[0].getHostAddress();
|
||||
}
|
||||
@ -113,10 +110,9 @@ public class NetworkAddress implements Serializable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return isdom ? StringUtil.format(
|
||||
"NetworkAddress(IP='{}',type='{}'," + "domain='{}')", ip, IPv,
|
||||
domain) :
|
||||
StringUtil.format("NetworkAddress(IP='{}',type='{}')", ip, IPv);
|
||||
return isdom?StringUtil.format("NetworkAddress(IP='{}',type='{}'," +
|
||||
"domain='{}')",ip,IPv,domain):
|
||||
StringUtil.format("NetworkAddress(IP='{}',type='{}')",ip,IPv);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user