Make LLB only bind to local ipv4 addresses
This commit is contained in:
parent
9a31b5654d
commit
051932f544
1 changed files with 7 additions and 6 deletions
|
|
@ -184,8 +184,8 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
services.Configure<LoggerFilterOptions>(options => options.MinLevel = LogLevel.None);
|
services.Configure<LoggerFilterOptions>(options => options.MinLevel = LogLevel.None);
|
||||||
}, (server) =>
|
}, (server) =>
|
||||||
{
|
{
|
||||||
server.Prefixes.Add($"http://{GetLocalIp()}:{port}/");
|
foreach(string ip in GetLocalIps())
|
||||||
server.Prefixes.Add($"http://*:{port}/");
|
server.Prefixes.Add($"http://{ip}:{port}/");
|
||||||
}).Build();
|
}).Build();
|
||||||
|
|
||||||
server.Router.Options.SendExceptionMessages = false;
|
server.Router.Options.SendExceptionMessages = false;
|
||||||
|
|
@ -199,19 +199,20 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLocalIp()
|
private static List<string> GetLocalIps()
|
||||||
{
|
{
|
||||||
var host = Dns.GetHostEntry(Dns.GetHostName());
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
||||||
|
List<string> bindableIPv4Addresses = new();
|
||||||
|
|
||||||
foreach (var ip in host.AddressList)
|
foreach (var ip in host.AddressList)
|
||||||
{
|
{
|
||||||
if (ip.AddressFamily == AddressFamily.InterNetwork && ip.ToString() != "127.0.0.1")
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
return ip.ToString();
|
bindableIPv4Addresses.Add(ip.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return bindableIPv4Addresses;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue