nixos-module/container/bird: simplify filter operations

This commit is contained in:
Astro 2021-04-30 00:16:00 +02:00
parent 67acfb140b
commit 6b6f3d5598
1 changed files with 7 additions and 7 deletions

View File

@ -40,14 +40,14 @@ in
''} ''}
${lib.optionalString isUpstream '' ${lib.optionalString isUpstream ''
export filter { export filter {
if net ~ [ 0.0.0.0/0 ] then { if net = 0.0.0.0/0 then {
# Do not set another default route on upstreams # Do not set another default route on upstreams
reject; reject;
} }
accept; accept;
}; };
import filter { import filter {
if net ~ [ 0.0.0.0/0 ] then { if net = 0.0.0.0/0 then {
# Learn the upstream default route # Learn the upstream default route
accept; accept;
} }
@ -64,7 +64,7 @@ in
''} ''}
${lib.optionalString isUpstream '' ${lib.optionalString isUpstream ''
export filter { export filter {
if net ~ [ ::/0 ] then { if net = ::/0 then {
# Do not set another default route on upstreams # Do not set another default route on upstreams
reject; reject;
} }
@ -72,7 +72,7 @@ in
}; };
# Learn the upstream default route # Learn the upstream default route
import filter { import filter {
if net ~ [ ::/0 ] then { if net = ::/0 then {
accept; accept;
} }
reject; reject;
@ -90,7 +90,7 @@ in
table master4; table master4;
peer table vpn4_table; peer table vpn4_table;
export filter { export filter {
if net ~ [ 0.0.0.0/0 ] then { if net = 0.0.0.0/0 then {
# Copy default route to vpn4 table # Copy default route to vpn4 table
accept; accept;
} }
@ -137,7 +137,7 @@ in
ipv4 { ipv4 {
export all; export all;
import filter { import filter {
if net ~ [ 0.0.0.0/0 ] then { if net = 0.0.0.0/0 then {
${(builtins.foldl' (result: gateway: { ${(builtins.foldl' (result: gateway: {
text = '' text = ''
${result.text} ${result.text}
@ -197,7 +197,7 @@ in
ipv6 { ipv6 {
export all; export all;
import filter { import filter {
if net ~ [ ::/0 ] then { if net = ::/0 then {
${(builtins.foldl' (result: gateway: { ${(builtins.foldl' (result: gateway: {
text = '' text = ''
${result.text} ${result.text}