Commit 600c0ef
committed
feat(rules): add priority field and configurable evaluation mode (#1460)
Add support for explicit rule ordering and configurable evaluation logic:
1. **Priority field**: Rules now have a `priority` field (int, default 0).
Lower values = higher priority. Rules are sorted by priority first,
then alphabetically by name. This replaces the implicit file naming
convention (000-, 001-, etc.) with explicit control.
2. **Evaluation modes**: New config option `Rules.EvaluationMode`:
- `deny-priority` (default): Current behavior where deny/reject rules
always win over allow rules, regardless of order
- `first-match`: RouterOS-style evaluation where the first matching
rule wins, giving full control via priority ordering
Example config:
```json
"Rules": {
"Path": "/etc/opensnitchd/rules/",
"EnableChecksums": false,
"EvaluationMode": "first-match"
}
```
Example rule with priority:
```json
{
"name": "block-malware",
"priority": -100,
"action": "deny",
...
}
```
This provides more intuitive and flexible rule ordering while maintaining
backwards compatibility with existing configurations.1 parent e3cf78c commit 600c0ef
File tree
5 files changed
+60
-5
lines changed- daemon
- data
- rule
- ui
- config
5 files changed
+60
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
55 | 73 | | |
56 | 74 | | |
57 | 75 | | |
| |||
374 | 392 | | |
375 | 393 | | |
376 | 394 | | |
377 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
378 | 405 | | |
379 | 406 | | |
380 | 407 | | |
| |||
494 | 521 | | |
495 | 522 | | |
496 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
497 | 527 | | |
498 | 528 | | |
499 | 529 | | |
500 | 530 | | |
501 | 531 | | |
502 | 532 | | |
503 | 533 | | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
508 | 543 | | |
509 | 544 | | |
510 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
50 | 60 | | |
51 | 61 | | |
52 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
0 commit comments