[Fix] Use Host if IPv6 address hostname
Fix for a part of pull request #264.
This commit is contained in:
parent
3b62c0f2ec
commit
91d12041a8
@ -157,7 +157,7 @@ namespace WebSocketSharp.Server
|
|||||||
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.DnsSafeHost;
|
var host = getHost (uri);
|
||||||
var addr = host.ToIPAddress ();
|
var addr = host.ToIPAddress ();
|
||||||
if (!addr.IsLocal ())
|
if (!addr.IsLocal ())
|
||||||
throw new ArgumentException ("The host part isn't a local host name: " + url, "url");
|
throw new ArgumentException ("The host part isn't a local host name: " + url, "url");
|
||||||
@ -638,6 +638,11 @@ namespace WebSocketSharp.Server
|
|||||||
: str;
|
: 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)
|
private void init (string hostname, System.Net.IPAddress address, int port, bool secure)
|
||||||
{
|
{
|
||||||
_hostname = hostname ?? convertToString (address);
|
_hostname = hostname ?? convertToString (address);
|
||||||
|
Loading…
Reference in New Issue
Block a user