Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 75ec005

Browse files
authored
Merge pull request #1390 from github/fixes/1234-machine-fingerprint
Fix calculating machine fingerprint.
2 parents 2e1f640 + 9d08acb commit 75ec005

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/GitHub.Api/ApiClientConfiguration.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public static string MachineFingerprint
4949
{
5050
get
5151
{
52-
return GetSha256Hash(Info.ApplicationInfo.ApplicationDescription + ":" + GetMachineIdentifier());
52+
return GetSha256Hash(
53+
Info.ApplicationInfo.ApplicationDescription + ":" +
54+
GetMachineIdentifier() + ":" +
55+
GetMachineNameSafe());
5356
}
5457
}
5558

@@ -60,13 +63,13 @@ static string GetMachineIdentifier()
6063
try
6164
{
6265
// adapted from http://stackoverflow.com/a/1561067
63-
var fastedValidNetworkInterface = NetworkInterface.GetAllNetworkInterfaces()
64-
.OrderBy(nic => nic.Speed)
66+
var fastestValidNetworkInterface = NetworkInterface.GetAllNetworkInterfaces()
67+
.OrderByDescending(nic => nic.Speed)
6568
.Where(nic => nic.OperationalStatus == OperationalStatus.Up)
6669
.Select(nic => nic.GetPhysicalAddress().ToString())
67-
.FirstOrDefault(address => address.Length > 12);
70+
.FirstOrDefault(address => address.Length >= 12);
6871

69-
return fastedValidNetworkInterface ?? GetMachineNameSafe();
72+
return fastestValidNetworkInterface ?? GetMachineNameSafe();
7073
}
7174
catch (Exception)
7275
{

0 commit comments

Comments
 (0)