diff --git a/roles/bird/filter_plugins/bird.py b/roles/bird/filter_plugins/bird.py index 5bfae8f..00f38bb 100644 --- a/roles/bird/filter_plugins/bird.py +++ b/roles/bird/filter_plugins/bird.py @@ -89,7 +89,7 @@ class IPv4orIPv6(BaseModel): ipv6: list[int] = Field(ge=0, min_items=2, max_items=2) -class IPFlag(str): +class IPFlag: @classmethod def __get_validators__(cls): yield cls.validate @@ -236,14 +236,8 @@ def str_of_condition(condition: Condition, ctx: bool) -> str: return f"{min_v6} <= net.len && net.len <= {max_v6}" case NetMatch(matches=matches): - if ctx.ipv4: - networks = [ - m for m in matches if isinstance(m[0], IPv4Network) - ] - else: - networks = [ - m for m in matches if isinstance(m[0], IPv6Network) - ] + networkType = IPv4Network if ctx.ipv4 else IPv6Network + networks = [m for m in matches if isinstance(m[0], networkType)] return f"net ~ [ {', '.join([f'{network}{flag}' for (network, flag) in networks])} ]"