1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-11-27 09:48:08 +00:00

Limit to only displaying 5 IPs at once (the android emulator sets up

about 20 interfaces somehow, which really spams the screen).
This commit is contained in:
Greg Alexander 2019-06-16 19:37:16 -04:00
parent 9fe01ea860
commit 23a2bda614

View File

@ -214,6 +214,7 @@ public class SimpleSSHD extends Activity
public static String get_ip(boolean pretty) {
String ret = "";
int num_ips = 0;
try {
List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface intf : interfaces) {
@ -226,14 +227,16 @@ public class SimpleSSHD extends Activity
if (i != -1) {
ip = ip.substring(0,i);
}
if (pretty) {
if (!ret.equals("")) {
ret += "\n";
}
ret += "IP: "+ ip;
} else {
if (!pretty) {
return ip;
}
if (num_ips++ >= 5) {
return ret+"...";
}
if (num_ips > 1) {
ret += "\n";
}
ret += "IP: " + ip;
}
}
}