aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/Devices
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-09-14 11:10:51 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-09-14 11:10:51 -0400
commit5c615fa02448813499ed87f2a1c2b937c7a7dcd5 (patch)
treeb96b07cb1d43006a8faa64649885fb808e18c43a /MediaBrowser.Common.Implementations/Devices
parent4f3ea6c6c3cdde7f4b8d21dc97c711635d73b4e0 (diff)
add connect linking
Diffstat (limited to 'MediaBrowser.Common.Implementations/Devices')
-rw-r--r--MediaBrowser.Common.Implementations/Devices/DeviceId.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/MediaBrowser.Common.Implementations/Devices/DeviceId.cs b/MediaBrowser.Common.Implementations/Devices/DeviceId.cs
index ce69843fb..5af236026 100644
--- a/MediaBrowser.Common.Implementations/Devices/DeviceId.cs
+++ b/MediaBrowser.Common.Implementations/Devices/DeviceId.cs
@@ -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