diff src/goodjava/io/IoUtils.java @ 1698:2dbcc8360a3e

backup security
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 27 Jun 2022 20:51:49 -0600
parents 08177ced7fa0
children 745f756e719b
line wrap: on
line diff
--- a/src/goodjava/io/IoUtils.java	Mon Jun 27 18:36:56 2022 -0600
+++ b/src/goodjava/io/IoUtils.java	Mon Jun 27 20:51:49 2022 -0600
@@ -8,9 +8,15 @@
 import java.io.Writer;
 import java.io.StringWriter;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Inet4Address;
+import java.net.NetworkInterface;
 import java.nio.file.Files;
 import java.nio.file.attribute.FileTime;
 import java.security.Security;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Enumeration;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.SSLServerSocketFactory;
 import goodjava.logging.Logger;
@@ -103,6 +109,17 @@
 		return cs;
 	}
 
+	public static Set<InetAddress> getInetAddresses() throws IOException {
+		Set<InetAddress> set = new HashSet<InetAddress>();
+		for( Enumeration<NetworkInterface> e1 = NetworkInterface.getNetworkInterfaces(); e1.hasMoreElements(); ) {
+			NetworkInterface ni = e1.nextElement();
+			for( Enumeration<InetAddress> e2 = ni.getInetAddresses(); e2.hasMoreElements(); ) {
+				InetAddress ia = e2.nextElement();
+				set.add(ia);
+			}
+		}
+		return set;
+	}
 
 
 	public static class ProcException extends IOException {