aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations
diff options
context:
space:
mode:
authorMichalis Adamidis <gsnerf@gsnerf.de>2014-09-14 18:00:44 +0200
committerMichalis Adamidis <gsnerf@gsnerf.de>2014-09-14 18:00:44 +0200
commit411a0531e0a71b2d458b5b3a8a9951ca763ca09a (patch)
tree871614a2cab9da0aa95d1d1f9f350d80fcf56271 /MediaBrowser.Common.Implementations
parent4f3ea6c6c3cdde7f4b8d21dc97c711635d73b4e0 (diff)
parent6a177d21478774b3ea1a5adc606935bb3aff65bf (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Common.Implementations')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs2
-rw-r--r--MediaBrowser.Common.Implementations/Devices/DeviceId.cs24
2 files changed, 23 insertions, 3 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 011dd76ee..c59d1a3b0 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -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;
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