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