1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) 2026 Erik Lening (hollowpointer) and Contributors
//
// This file is part of Zond Engine, licensed under the GNU Affero General
// Public License, version 3 or later. See the LICENSE file for details, or
// <https://www.gnu.org/licenses/agpl-3.0.html>.
//
// SPDX-License-Identifier: AGPL-3.0-or-later
//! # Written down, and read back
//!
//! The grammars that turn what a person typed into the values in
//! [`crate::model`]. [`ip`] handles the address half, covering literals,
//! ranges, CIDR blocks, zones and keywords. [`target`] handles an address with
//! a port specification after it.
//!
//! These grammars live beside the model rather than beside the file formats
//! because every way of naming a target ends here. A command-line argument, a
//! form field, a line of a target list, a row of somebody's CSV and a hostname
//! read out of an nmap report are one expression arriving from different places.
//! Writing the grammar once leaves the formats above deciding only where the
//! tokens come from, with none of them able to drift into a slightly different
//! dialect.
//!
//! Resolution that needs to ask the machine anything, such as what `lan` means
//! or which interface a `%zone` names, arrives as a caller-supplied callback
//! ([`ip::ResolverFn`], [`ip::ZoneResolverFn`]). That is what keeps this a leaf:
//! the engine passes [`crate::system::interface`]'s answers in, rather than this
//! module reaching out for them.
pub use ;
pub use ;
use cratePortSet;
use crateTargetMap;
/// Parses target expressions such as `["1.1.1.1:80,443", "8.8.8.8"]` into a
/// [`TargetMap`], giving each one the ports it names or `global_ports` if it
/// names none.
///
/// The shape of [`target::to_target_map`] that takes a keyword resolver and
/// nothing else. To resolve interface zones or hostnames as well, build a
/// [`TargetContext`] and call that function directly.
///
/// # Errors
///
/// The first expression that does not parse. Nothing is returned partially, so
/// a caller that wants to log the bad lines and scan the rest should drive
/// [`TargetMapBuilder`] itself.
// ╔════════════════════════════════════════════╗
// ║ ████████╗███████╗███████╗████████╗███████╗ ║
// ║ ╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██╔════╝ ║
// ║ ██║ █████╗ ███████╗ ██║ ███████╗ ║
// ║ ██║ ██╔══╝ ╚════██║ ██║ ╚════██║ ║
// ║ ██║ ███████╗███████║ ██║ ███████║ ║
// ║ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ║
// ╚════════════════════════════════════════════╝