"""Blacklist [drop.sync] specific rules customization."""
from typing import Iterator

from im360.internals.core.firewall import FirewallRules
from defence360agent.utils.validate import IPVersion

from .types_ import FirewallRule


def rules(
    ipset_name: str,
    ip_version: IPVersion,
    priority=FirewallRules.BLACKLIST_PRIORITY,
) -> Iterator[FirewallRule]:
    """Yield iptables *ip_version* drop.sync rules for *ipset_name*."""
    yield FirewallRule(
        rule=FirewallRules.ipset_rule(
            ipset_name, FirewallRules.LOG_BLACKLIST_CHAIN
        ),
        priority=priority,
    )
