mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
Merge pull request #2389 from Ivan-L/dev
Do not update wan.dat if WAN IP has not changed
This commit is contained in:
commit
a47042d5e3
@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.Connect
|
|||||||
public class ConnectEntryPoint : IServerEntryPoint
|
public class ConnectEntryPoint : IServerEntryPoint
|
||||||
{
|
{
|
||||||
private ITimer _timer;
|
private ITimer _timer;
|
||||||
|
private IpAddressInfo _cachedIpAddress;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
private readonly IApplicationPaths _appPaths;
|
private readonly IApplicationPaths _appPaths;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
@ -151,6 +152,12 @@ namespace Emby.Server.Implementations.Connect
|
|||||||
|
|
||||||
private void CacheAddress(IpAddressInfo address)
|
private void CacheAddress(IpAddressInfo address)
|
||||||
{
|
{
|
||||||
|
if (_cachedIpAddress != null && _cachedIpAddress.Equals(address))
|
||||||
|
{
|
||||||
|
// no need to update the file if the address has not changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var path = CacheFilePath;
|
var path = CacheFilePath;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -164,6 +171,7 @@ namespace Emby.Server.Implementations.Connect
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8);
|
_fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8);
|
||||||
|
_cachedIpAddress = address;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -184,6 +192,7 @@ namespace Emby.Server.Implementations.Connect
|
|||||||
|
|
||||||
if (_networkManager.TryParseIpAddress(endpoint, out ipAddress))
|
if (_networkManager.TryParseIpAddress(endpoint, out ipAddress))
|
||||||
{
|
{
|
||||||
|
_cachedIpAddress = ipAddress;
|
||||||
((ConnectManager)_connectManager).OnWanAddressResolved(ipAddress);
|
((ConnectManager)_connectManager).OnWanAddressResolved(ipAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user