nff: improve diagnostics and vmap expression handling in parser and formatter
This commit is contained in:
parent
c4a71f2e85
commit
e0f93d0307
3 changed files with 30 additions and 10 deletions
|
|
@ -175,10 +175,11 @@ impl NftablesFormatter {
|
|||
// Add policy on the same line if present
|
||||
if let Some(policy) = &chain.policy {
|
||||
write!(output, " policy {}", policy).unwrap();
|
||||
output.push_str(";\n");
|
||||
} else {
|
||||
output.push_str("\n");
|
||||
}
|
||||
|
||||
output.push_str(";\n");
|
||||
|
||||
if !chain.rules.is_empty() && !self.config.optimize {
|
||||
output.push('\n');
|
||||
}
|
||||
|
|
@ -294,8 +295,11 @@ impl NftablesFormatter {
|
|||
}
|
||||
|
||||
Expression::Vmap { expr, map } => {
|
||||
self.format_expression(output, expr);
|
||||
output.push_str(" vmap { ");
|
||||
if let Some(expr) = expr {
|
||||
self.format_expression(output, expr);
|
||||
output.push(' ');
|
||||
}
|
||||
output.push_str("vmap { ");
|
||||
for (i, (key, value)) in map.iter().enumerate() {
|
||||
if i > 0 {
|
||||
output.push_str(", ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue