[Fix] Use Host if IPv6 address hostname

Fix for a part of pull request #264.
This commit is contained in:
sta 2016-05-30 15:02:46 +09:00
parent 3b62c0f2ec
commit 91d12041a8

View File

@ -157,7 +157,7 @@ namespace WebSocketSharp.Server
if (!tryCreateUri (url, out uri, out msg))
throw new ArgumentException (msg, "url");
var host = uri.DnsSafeHost;
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");
@ -638,6 +638,11 @@ namespace WebSocketSharp.Server
: str;
}
private static string getHost (Uri uri)
{
return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost;
}
private void init (string hostname, System.Net.IPAddress address, int port, bool secure)
{
_hostname = hostname ?? convertToString (address);