[Modify] Polish it

This commit is contained in:
sta 2021-07-05 20:42:13 +09:00
parent d0af40181e
commit f81c6e99aa

View File

@ -161,19 +161,22 @@ namespace WebSocketSharp.Server
Uri uri; Uri uri;
string msg; string msg;
if (!tryCreateUri (url, out uri, out msg)) if (!tryCreateUri (url, out uri, out msg))
throw new ArgumentException (msg, "url"); throw new ArgumentException (msg, "url");
var host = uri.GetDnsSafeHost (true); var host = uri.GetDnsSafeHost (true);
var addr = host.ToIPAddress (); var addr = host.ToIPAddress ();
if (addr == null) { if (addr == null) {
msg = "The host part could not be converted to an IP address."; msg = "The host part could not be converted to an IP address.";
throw new ArgumentException (msg, "url"); throw new ArgumentException (msg, "url");
} }
if (!addr.IsLocal ()) { if (!addr.IsLocal ()) {
msg = "The IP address of the host is not a local IP address."; msg = "The IP address of the host is not a local IP address.";
throw new ArgumentException (msg, "url"); throw new ArgumentException (msg, "url");
} }