feat: support newline-separated hosts and shorthand ranges - #3568
Conversation
Host input (IP Scanner, Port Scanner, Ping Monitor) now accepts newline-separated entries, so a column pasted from Excel works directly (one IP/range per line). The existing semicolon-separated format keeps working. Shorthand IPv4 ranges like 192.168.0.1-100 (192.168.0.1 to 192.168.0.100) are now supported too, alongside the existing full-range format 192.168.0.1-192.168.0.100. - HostRangeHelper.CreateListFromInput: split on ';', CR, LF - HostRangeHelper.ResolveAsync: expand shorthand ranges - RegexHelper: add IPv4AddressShortRangeRegex - MultipleHostsRangeValidator: accept newlines + shorthand ranges - Docs: document both features
…anges Co-Authored-By: Claude <noreply@anthropic.com>
|
Tick the box to add this pull request to the merge queue (same as
|
…aste The WPF TextBox inside an editable ComboBox has AcceptsReturn=false, so pasting multiline text (e.g. a column from Excel) silently drops everything after the first line. Add a ComboBoxPasteBehavior attached property that rewrites the clipboard content to the semicolon-separated form in CommandManager.PreviewExecuted, before the paste command runs. Applied to the host input of IP Scanner, Port Scanner and Ping Monitor. Co-Authored-By: Claude <noreply@anthropic.com>
|
@dearmb thanks! I like the idea that we convert the data when it's pasted. Will review it in the next days when i have some time :) Edit: We already support this syntax to replace any octet with a range:
|
…aste in port input Apply the same paste conversion to the Ports field of the Port Scanner, so a column of ports pasted from Excel works as well. Co-Authored-By: Claude <noreply@anthropic.com>
00dace5 to
64bf417
Compare
… IPv4 ranges as example input
There was a problem hiding this comment.
Pull request overview
Adds newline-separated input and shorthand IPv4 ranges across the three network tools.
Changes:
- Parses newline-separated hosts and shorthand ranges.
- Converts multiline clipboard input for editable combo boxes.
- Updates examples, documentation, and changelog.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Website/docs/changelog/next-release.md |
Records the new input formats. |
Website/docs/application/port-scanner.md |
Documents scanner input syntax. |
Website/docs/application/ping-monitor.md |
Documents monitor input syntax. |
Website/docs/application/ip-scanner.md |
Documents scanner input syntax. |
Source/NETworkManager/Views/PortScannerView.xaml |
Enables multiline paste conversion. |
Source/NETworkManager/Views/PingMonitorHostView.xaml |
Enables multiline paste conversion. |
Source/NETworkManager/Views/IPScannerView.xaml |
Enables multiline paste conversion. |
Source/NETworkManager.Validators/MultipleHostsRangeValidator.cs |
Validates new separators and shorthand ranges. |
Source/NETworkManager.Utilities/RegexHelper.cs |
Adds shorthand-range matching. |
Source/NETworkManager.Models/Network/HostRangeHelper.cs |
Parses and expands the new formats. |
Source/NETworkManager.Localization/Resources/StaticStrings.resx |
Updates the range example. |
Source/NETworkManager.Localization/Resources/StaticStrings.Designer.cs |
Synchronizes the generated resource description. |
Source/NETworkManager.Controls/ComboBoxPasteBehavior.cs |
Implements multiline paste conversion. |
Files not reviewed (1)
- Source/NETworkManager.Localization/Resources/StaticStrings.Designer.cs: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Parallel.For(IPv4Address.ToInt32(IPAddress.Parse(shortRange[0])), | ||
| IPv4Address.ToInt32(IPAddress.Parse($"{shortBase}.{shortRange[1]}")) + 1, (i, state) => | ||
| { | ||
| if (ct.IsCancellationRequested) | ||
| state.Break(); | ||
|
|
||
| hostsBag.Add((IPv4Address.FromInt32(i), string.Empty)); | ||
| }); |
| try | ||
| { | ||
| Clipboard.SetText(converted); | ||
| } | ||
| catch (ExternalException) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Restore the original clipboard content once the paste command has consumed the | ||
| // rewritten text, so pasting elsewhere afterwards still yields what the user actually copied. | ||
| Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, () => | ||
| { | ||
| try | ||
| { | ||
| Clipboard.SetText(originalText); | ||
| } | ||
| catch (ExternalException) | ||
| { | ||
| // Best effort - leave the rewritten text on the clipboard if restoring fails. | ||
| } | ||
| }); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- Source/NETworkManager.Localization/Resources/StaticStrings.Designer.cs: Generated file
Suppressed comments (1)
Source/NETworkManager.Validators/MultipleHostsRangeValidator.cs:24
- Reject inputs that contain only separators. With
RemoveEmptyEntries, values such as";","\r\n", or a paste containing only blank rows produce zero entries and this validator returns valid;EmptyValidatordoes not catch them because the original string is non-empty. The scan button can then start with no hosts. Keep ignoring empty entries between valid hosts, but explicitly fail when the resulting array is empty.
foreach (var ipHostOrRange in ((string)value)
.Replace(" ", "")
.Split([';', '\r', '\n'], StringSplitOptions.RemoveEmptyEntries))

Changes proposed in this pull request
;) separator. The oldIP;IP;IPsyntax keeps working unchanged.192.168.0.1-100, which expand to192.168.0.1up to192.168.0.100. Full ranges (192.168.0.1-192.168.0.100), CIDR, wildcard octets and hostnames all keep working as before.Implementation notes
The three tools share a single host parser (
HostRangeHelper.CreateListFromInput) and a single WPF validation rule (MultipleHostsRangeValidator), so the change is minimal and covers all of them at once:HostRangeHelper.CreateListFromInputnow splits on;, CR and LF while ignoring empty entries.MultipleHostsRangeValidatoruses the same separators and recognizes shorthand ranges.RegexHelper.IPv4AddressShortRangeRegexmatches shorthand ranges like192.168.0.1-100.HostRangeHelper.ResolveAsyncexpands shorthand ranges into the full IP list (the sameParallel.Forexpansion used for full ranges, so cross-octet shorthand like10.0.0.254-10.0.1.2works too).Related issue(s)
Copilot generated summary
Copilot summary
Host inputs in the IP Scanner, Port Scanner and Ping Monitor now accept newline-separated hosts in addition to the existing semicolon separator, so lists can be pasted directly from Excel. Shorthand IPv4 ranges such as
192.168.0.1-100are also supported. The shared parser and validator were updated, and documentation for all three tools was refreshed.To-Do
Contributing
By submitting this pull request, I confirm the following: