Skip to content

Commit

Permalink
Add cross-plattform arp capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-jung committed Dec 13, 2019
1 parent fab76bf commit 28fbbb6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ You can add the application in IIS for more serious hosting. You can set up T-SQ

## Known Limitations

* Adding hosts by hostname is currently impossible on linux, as the ARP API is windows specific.
* Adding hosts by hostname is currently impossible on platforms except Windows and Linux, as there is no appropriate ARP API.
6 changes: 3 additions & 3 deletions WoL/Pages/AddHost.razor
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@
{
host = await GetHost();
}
catch (DllNotFoundException ex)
catch (PlatformNotSupportedException ex)
{
L.LogInformation(ex, $"DllNotFound during name resolution or determination of mac address. Page: {nameof(AddHost)}");
Alert = "This operation is not supported on the operating system this application is running on. Adding hosts by hostname is currently not supported on linux due to the lack of an appropriate ARP API.";
L.LogInformation(ex, $"PlatformNotSupported during name resolution or determination of mac address. Page: {nameof(AddHost)}");
Alert = "This operation is not supported on the operating system this application is running on. Adding hosts by hostname is currently not supported on Mac OS X due to the lack of an appropriate ARP API.";
Creating = false;
return;
}
Expand Down
4 changes: 1 addition & 3 deletions WoL/Services/AddressLookupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public class AddressLookupService : IAddressLookupService

public async Task<PhysicalAddress> GetMac(IPAddress ip)
{
var res = await ArpRequest.SendAsync(ip).ConfigureAwait(false);
if (res.Exception != null) throw res.Exception;
return res.Address;
return await ArpLookup.Arp.LookupAsync(ip).ConfigureAwait(false);
}
}
}
1 change: 1 addition & 0 deletions WoL/WoL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArpLookup" Version="0.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 28fbbb6

Please sign in to comment.