MCPcopy Create free account
hub / github.com/FongMi/TV / getHostAddress

Method getHostAddress

catvod/src/main/java/com/github/catvod/utils/Util.java:132–144  ·  view source on GitHub ↗
(String keyword)

Source from the content-addressed store, hash-verified

130 }
131
132 private static String getHostAddress(String keyword) throws SocketException {
133 for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
134 NetworkInterface nif = en.nextElement();
135 if (!keyword.isEmpty() && !nif.getName().startsWith(keyword)) continue;
136 for (Enumeration<InetAddress> addresses = nif.getInetAddresses(); addresses.hasMoreElements(); ) {
137 InetAddress addr = addresses.nextElement();
138 if (!addr.isLoopbackAddress() && addr instanceof Inet4Address) {
139 return addr.getHostAddress();
140 }
141 }
142 }
143 return "";
144 }
145}

Callers 1

getIpMethod · 0.95

Calls 3

isEmptyMethod · 0.45
startsWithMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected