From fb4a07ec6eb8be0a76548e2a4aee2c9e9141f842 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 14:48:31 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0928d2c8..672c09cd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -161,9 +161,17 @@ namespace WebSocketSharp.Server throw new ArgumentException (msg, "url"); var host = getHost (uri); + var addr = host.ToIPAddress (); - if (!addr.IsLocal ()) - throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); + if (addr == null) { + msg = "The host part could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); + } + + if (!addr.IsLocal ()) { + msg = "The IP address of the host is not a local IP address."; + throw new ArgumentException (msg, "url"); + } init (host, addr, uri.Port, uri.Scheme == "https"); }