Merge pull request #239 from CmTheLuke/patch-1

UI.cs - Listen to "localhost" by default
This commit is contained in:
Frank A. Krueger 2020-04-03 10:27:44 -07:00 committed by GitHub
commit f34dd84ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -34,7 +34,7 @@ namespace Ooui
static string host = "*";
public static string Host {
get => host;
get => host == "*" ? "localhost" : host;
set {
if (!string.IsNullOrWhiteSpace (value) && host != value) {
host = value;
@ -216,8 +216,7 @@ namespace Ooui
public static string GetUrl (string path)
{
var localhost = host == "*" ? "localhost" : host;
var url = $"http://{localhost}:{port}{path}";
var url = $"http://{Host}:{port}{path}";
return url;
}
@ -236,7 +235,7 @@ namespace Ooui
if (serverCts != null) return;
serverCts = new CancellationTokenSource ();
var token = serverCts.Token;
var listenerPrefix = $"http://{host}:{port}/";
var listenerPrefix = $"http://{Host}:{port}/";
Task.Run (() => RunAsync (listenerPrefix, token), token);
}