Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for NetworkInformationException #630

Merged
merged 3 commits into from
Jan 22, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions SteamKit2/SteamKit2/Util/HardwareUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ public override byte[] GetMacAddress()
// mono seems to have a pretty solid implementation of NetworkInterface for our platforms
// if it turns out to be buggy we can always roll our own and poke into /sys/class/net on nix

var firstEth = NetworkInterface.GetAllNetworkInterfaces()
.Where( i => i.NetworkInterfaceType == NetworkInterfaceType.Ethernet || i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 )
.FirstOrDefault();
try {
felipe19930 marked this conversation as resolved.
Show resolved Hide resolved
var firstEth = NetworkInterface.GetAllNetworkInterfaces()
.Where( i => i.NetworkInterfaceType == NetworkInterfaceType.Ethernet || i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 )
.FirstOrDefault();

if ( firstEth == null )
{
// well...
return Encoding.UTF8.GetBytes( "SteamKit-MacAddress" );
if ( firstEth != null )
{
return firstEth.GetPhysicalAddress().GetAddressBytes();
}
}

return firstEth.GetPhysicalAddress().GetAddressBytes();
catch( NetworkInformationException ) {
felipe19930 marked this conversation as resolved.
Show resolved Hide resolved
// See: https://github.com/SteamRE/SteamKit/issues/629
}
// well...
return Encoding.UTF8.GetBytes( "SteamKit-MacAddress" );
}

public override byte[] GetDiskId()
Expand Down