changeset 701:d0280c7fdc3a

add Io.ip()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 04 May 2016 17:49:41 -0600
parents 61b36d5895df
children 87970832a3c3
files core/src/luan/modules/Io.luan core/src/luan/modules/IoLuan.java
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r 61b36d5895df -r d0280c7fdc3a core/src/luan/modules/Io.luan
--- a/core/src/luan/modules/Io.luan	Mon May 02 21:54:24 2016 -0600
+++ b/core/src/luan/modules/Io.luan	Wed May 04 17:49:41 2016 -0600
@@ -4,6 +4,7 @@
 
 local M = {}
 
+M.ip = IoLuan.ip
 M.read_console_line = IoLuan.read_console_line
 M.schemes = IoLuan.newSchemes()
 M.uri = IoLuan.uri
diff -r 61b36d5895df -r d0280c7fdc3a core/src/luan/modules/IoLuan.java
--- a/core/src/luan/modules/IoLuan.java	Mon May 02 21:54:24 2016 -0600
+++ b/core/src/luan/modules/IoLuan.java	Wed May 04 17:49:41 2016 -0600
@@ -24,7 +24,9 @@
 import java.net.URL;
 import java.net.Socket;
 import java.net.ServerSocket;
+import java.net.InetAddress;
 import java.net.MalformedURLException;
+import java.net.UnknownHostException;
 import java.util.List;
 import java.util.ArrayList;
 import luan.Luan;
@@ -673,6 +675,15 @@
 	}
 
 
+	public static String ip(String domain) {
+		try {
+			return InetAddress.getByName(domain).getHostAddress();
+		} catch(UnknownHostException e) {
+			return null;
+		}
+	}
+
+
 	// security
 
 	public interface Security {