Skip to content

feat: support newline-separated hosts and shorthand ranges - #3568

Merged
mergify[bot] merged 6 commits into
BornToBeRoot:mainfrom
dearmb:feature/paste-host-list
Aug 15, 2026
Merged

feat: support newline-separated hosts and shorthand ranges#3568
mergify[bot] merged 6 commits into
BornToBeRoot:mainfrom
dearmb:feature/paste-host-list

Conversation

@dearmb

@dearmb dearmb commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request

  • Host input fields in the IP Scanner, Port Scanner and Ping Monitor now accept newline-separated hosts (one input per line, e.g. when pasting a column from Excel) in addition to the existing semicolon (;) separator. The old IP;IP;IP syntax keeps working unchanged.
  • Added support for shorthand IPv4 ranges like 192.168.0.1-100, which expand to 192.168.0.1 up to 192.168.0.100. Full ranges (192.168.0.1-192.168.0.100), CIDR, wildcard octets and hostnames all keep working as before.
  • Updated the documentation for all three tools to mention the newline separator and the shorthand range format.

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.CreateListFromInput now splits on ;, CR and LF while ignoring empty entries.
  • MultipleHostsRangeValidator uses the same separators and recognizes shorthand ranges.
  • A new RegexHelper.IPv4AddressShortRangeRegex matches shorthand ranges like 192.168.0.1-100.
  • HostRangeHelper.ResolveAsync expands shorthand ranges into the full IP list (the same Parallel.For expansion used for full ranges, so cross-octet shorthand like 10.0.0.254-10.0.1.2 works too).

Related issue(s)

  • None

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-100 are 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:

dearmb and others added 2 commits August 10, 2026 01:28
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>
@mergify

mergify Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

…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>
@BornToBeRoot

BornToBeRoot commented Aug 9, 2026

Copy link
Copy Markdown
Owner

@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: 10.8.10.[100-200] So you could already scan all gateways for example: 10.8.[0-10].1.

image

…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>
@dearmb
dearmb force-pushed the feature/paste-host-list branch from 00dace5 to 64bf417 Compare August 10, 2026 04:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +75 to +82
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));
});
Comment on lines +80 to +101
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.
}
});

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; EmptyValidator does 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))

@mergify
mergify Bot merged commit ea150ad into BornToBeRoot:main Aug 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants