changeset 1176:79b1e9ffd0c0

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 12 Feb 2018 15:19:00 -0700
parents d6d0bd05ad8c
children 26533dd4cd09
files src/luan/modules/http/Server.luan src/luan/webserver/Server.java
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/http/Server.luan	Mon Feb 12 14:55:28 2018 -0700
+++ b/src/luan/modules/http/Server.luan	Mon Feb 12 15:19:00 2018 -0700
@@ -93,7 +93,7 @@
 	handler = ContentTypeHandler.new(handler)
 	handler = SafeHandler.new(handler)
 	handler = LogHandler.new(handler)
-	Server.server = JavaServer.Local.new(Server.port,handler)
+	Server.server = JavaServer.ForAddress.new("127.0.0.1",Server.port,handler)
 	start()
 end
 
--- a/src/luan/webserver/Server.java	Mon Feb 12 14:55:28 2018 -0700
+++ b/src/luan/webserver/Server.java	Mon Feb 12 15:19:00 2018 -0700
@@ -4,6 +4,7 @@
 import java.net.Socket;
 import java.net.ServerSocket;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -58,13 +59,20 @@
 		}
 	}
 
-	public static class Local extends Server {
-		public Local(int port,Handler handler) {
+	public static class ForAddress extends Server {
+		private final InetAddress addr;
+
+		public ForAddress(InetAddress addr,int port,Handler handler) {
 			super(port,handler);
+			this.addr = addr;
+		}
+
+		public ForAddress(String addrName,int port,Handler handler) throws UnknownHostException {
+			this(InetAddress.getByName(addrName),port,handler);
 		}
 
 		protected ServerSocket newServerSocket() throws IOException {
-			return new ServerSocket(port,0,InetAddress.getByName("127.0.0.1"));
+			return new ServerSocket(port,0,addr);
 		}
 	}
 }