Skip to content

Commit d24a0b5

Browse files
committed
fix naming
1 parent bd31d3b commit d24a0b5

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/Smdn.Net.AddressResolution/Smdn.Net.AddressResolution.Arp/ProcfsArpMacAddressResolver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ internal partial class ProcfsArpMacAddressResolver : MacAddressResolver {
3232
);
3333
}
3434

35-
if (ProcfsArpNmapScanMacAddressResolver.IsSupported) {
36-
return new ProcfsArpNmapScanMacAddressResolver(
35+
if (ProcfsArpWithNmapCommandMacAddressResolver.IsSupported) {
36+
return new ProcfsArpWithNmapCommandMacAddressResolver(
3737
options: options,
38-
logger: serviceProvider?.GetService<ILoggerFactory>()?.CreateLogger<ProcfsArpNmapScanMacAddressResolver>()
38+
logger: serviceProvider?.GetService<ILoggerFactory>()?.CreateLogger<ProcfsArpWithNmapCommandMacAddressResolver>()
3939
);
4040
}
4141

src/Smdn.Net.AddressResolution/Smdn.Net.AddressResolution.Arp/ProcfsArpWithNmapCommandMacAddressResolver.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Smdn.Net.AddressResolution.Arp;
1414

15-
internal sealed class ProcfsArpNmapScanMacAddressResolver : ProcfsArpMacAddressResolver {
15+
internal sealed class ProcfsArpWithNmapCommandMacAddressResolver : ProcfsArpMacAddressResolver {
1616
// ref: https://nmap.org/book/man-briefoptions.html
1717
// -sn: Ping Scan - disable port scan
1818
// -n: Never do DNS resolution
@@ -21,12 +21,12 @@ internal sealed class ProcfsArpNmapScanMacAddressResolver : ProcfsArpMacAddressR
2121
// -oG <file>: Output scan in Grepable format
2222
private const string NmapCommandBaseOptions = "-sn -n -T4 -oG - ";
2323

24-
public static new bool IsSupported => ProcfsArpMacAddressResolver.IsSupported && lazyPathToNmap.Value is not null;
24+
public static new bool IsSupported => ProcfsArpMacAddressResolver.IsSupported && lazyPathToNmapCommand.Value is not null;
2525

26-
private static readonly Lazy<string?> lazyPathToNmap = new(valueFactory: GetPathToNmap, isThreadSafe: true);
26+
private static readonly Lazy<string?> lazyPathToNmapCommand = new(valueFactory: GetPathToNmapCommand, isThreadSafe: true);
2727
private static readonly string[] BinDirs = new[] { "/bin/", "/sbin/", "/usr/bin/" };
2828

29-
private static string? GetPathToNmap()
29+
private static string? GetPathToNmapCommand()
3030
=> BinDirs
3131
.Select(static dir => Path.Combine(dir, "nmap"))
3232
.FirstOrDefault(static nmap => File.Exists(nmap));
@@ -37,7 +37,7 @@ internal sealed class ProcfsArpNmapScanMacAddressResolver : ProcfsArpMacAddressR
3737
private readonly string nmapCommandCommonOptions;
3838
private readonly string nmapCommandFullScanOptions;
3939

40-
public ProcfsArpNmapScanMacAddressResolver(
40+
public ProcfsArpWithNmapCommandMacAddressResolver(
4141
MacAddressResolverOptions options,
4242
ILogger? logger
4343
)
@@ -46,22 +46,22 @@ public ProcfsArpNmapScanMacAddressResolver(
4646
logger
4747
)
4848
{
49-
if (string.IsNullOrEmpty(options.NmapInterfaceSpecification))
49+
if (string.IsNullOrEmpty(options.NmapCommandInterfaceSpecification))
5050
nmapCommandCommonOptions = NmapCommandBaseOptions;
5151
else
5252
// -e <iface>: Use specified interface
53-
nmapCommandCommonOptions = NmapCommandBaseOptions + $"-e {options.NmapInterfaceSpecification} ";
53+
nmapCommandCommonOptions = NmapCommandBaseOptions + $"-e {options.NmapCommandInterfaceSpecification} ";
5454

5555
nmapCommandFullScanOptions = string.Concat(
5656
nmapCommandCommonOptions,
57-
options.NmapTargetSpecification
58-
?? throw new ArgumentException($"{nameof(options.NmapTargetSpecification)} must be specified with {nameof(MacAddressResolverOptions)}")
57+
options.NmapCommandTargetSpecification
58+
?? throw new ArgumentException($"{nameof(options.NmapCommandTargetSpecification)} must be specified with {nameof(MacAddressResolverOptions)}")
5959
);
6060
}
6161

6262
protected override ValueTask ArpFullScanAsyncCore(CancellationToken cancellationToken)
6363
// perform full scan
64-
=> NmapScanAsync(
64+
=> RunNmapCommandAsync(
6565
nmapCommandOptions: nmapCommandFullScanOptions,
6666
logger: Logger,
6767
cancellationToken: cancellationToken
@@ -77,21 +77,21 @@ CancellationToken cancellationToken
7777

7878
return nmapCommandOptionTargetSpecification.Length == 0
7979
? default // do nothing
80-
: NmapScanAsync(
80+
: RunNmapCommandAsync(
8181
nmapCommandOptions: nmapCommandCommonOptions + nmapCommandOptionTargetSpecification,
8282
logger: Logger,
8383
cancellationToken: cancellationToken
8484
);
8585
}
8686

87-
private static async ValueTask NmapScanAsync(
87+
private static async ValueTask RunNmapCommandAsync(
8888
string nmapCommandOptions,
8989
ILogger? logger,
9090
CancellationToken cancellationToken
9191
)
9292
{
9393
var nmapCommandProcessStartInfo = new ProcessStartInfo() {
94-
FileName = lazyPathToNmap.Value,
94+
FileName = lazyPathToNmapCommand.Value,
9595
Arguments = nmapCommandOptions,
9696
RedirectStandardOutput = true,
9797
RedirectStandardError = true,

src/Smdn.Net.AddressResolution/Smdn.Net.AddressResolution/MacAddressResolverOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public sealed class MacAddressResolverOptions {
1010
/// <summary>
1111
/// Gets the string value passed to the argument '-e &lt;iface&gt;' of nmap command.
1212
/// </summary>
13-
public string? NmapInterfaceSpecification { get; init; }
13+
public string? NmapCommandInterfaceSpecification { get; init; }
1414

1515
/// <summary>
1616
/// Gets the string value passed to the argument &lt;target specification&gt; of nmap command.
1717
/// </summary>
18-
public string? NmapTargetSpecification { get; init; }
18+
public string? NmapCommandTargetSpecification { get; init; }
1919

2020
/// <summary>
2121
/// Gets the string value passed to the argument '--interface=&lt;s&gg;' of arp-scan command.

tests/Smdn.Net.AddressResolution/Smdn.Net.AddressResolution/MacAddressResolver.Create.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void Create()
1313
{
1414
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/proc/net/arp")) {
1515
var options = new MacAddressResolverOptions() {
16-
NmapTargetSpecification = "127.0.0.1"
16+
NmapCommandTargetSpecification = "127.0.0.1"
1717
};
1818
var resolver = MacAddressResolver.Create(options);
1919

0 commit comments

Comments
 (0)