mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-14 22:26:34 +00:00
add connect linking
This commit is contained in:
@@ -186,7 +186,7 @@ namespace MediaBrowser.Common.Implementations
|
||||
{
|
||||
if (_deviceId == null)
|
||||
{
|
||||
_deviceId = new DeviceId(ApplicationPaths, LogManager.GetLogger("SystemId"));
|
||||
_deviceId = new DeviceId(ApplicationPaths, LogManager.GetLogger("SystemId"), NetworkManager);
|
||||
}
|
||||
|
||||
return _deviceId.Value;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -9,6 +11,7 @@ namespace MediaBrowser.Common.Implementations.Devices
|
||||
public class DeviceId
|
||||
{
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly INetworkManager _networkManager;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly object _syncLock = new object();
|
||||
@@ -67,7 +70,23 @@ namespace MediaBrowser.Common.Implementations.Devices
|
||||
|
||||
private string GetNewId()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
// When generating an Id, base it off of the app path + mac address
|
||||
// But we can't fail here, so if we can't get the mac address then just use a random guid
|
||||
|
||||
string mac;
|
||||
|
||||
try
|
||||
{
|
||||
mac = _networkManager.GetMacAddress();
|
||||
}
|
||||
catch
|
||||
{
|
||||
mac = Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
mac += "-" + _appPaths.ApplicationPath;
|
||||
|
||||
return mac.GetMD5().ToString("N");
|
||||
}
|
||||
|
||||
private string GetDeviceId()
|
||||
@@ -85,10 +104,11 @@ namespace MediaBrowser.Common.Implementations.Devices
|
||||
|
||||
private string _id;
|
||||
|
||||
public DeviceId(IApplicationPaths appPaths, ILogger logger)
|
||||
public DeviceId(IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
_logger = logger;
|
||||
_networkManager = networkManager;
|
||||
}
|
||||
|
||||
public string Value
|
||||
|
||||
Reference in New Issue
Block a user