mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-05-20 23:02:33 -04:00
Allow changing listening ip addresses (#1713)
* Allow changing listening ip address * Use Json serialize for appsettings.config saving * BOM * IP Address validation * ip address reset * ValidIpAddress regex
This commit is contained in:
+20
-2
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
@@ -173,7 +173,25 @@ public class Program
|
||||
{
|
||||
webBuilder.UseKestrel((opts) =>
|
||||
{
|
||||
opts.ListenAnyIP(HttpPort, options => { options.Protocols = HttpProtocols.Http1AndHttp2; });
|
||||
var ipAddresses = Configuration.IpAddresses;
|
||||
if (ipAddresses == null || ipAddresses.Length == 0)
|
||||
{
|
||||
opts.ListenAnyIP(HttpPort, options => { options.Protocols = HttpProtocols.Http1AndHttp2; });
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(var ipAddress in ipAddresses.Split(','))
|
||||
{
|
||||
try {
|
||||
var address = System.Net.IPAddress.Parse(ipAddress.Trim());
|
||||
opts.Listen(address, HttpPort, options => { options.Protocols = HttpProtocols.Http1AndHttp2; });
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Could not parse ip addess '{0}'", ipAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
webBuilder.UseStartup<Startup>();
|
||||
|
||||
Reference in New Issue
Block a user