Skip to content

Commit

Permalink
chore(rich): make Rich_IcmpType hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
erig0 committed Sep 25, 2024
1 parent 38d0370 commit 3a4f695
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/firewall/core/rich.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,20 @@ def __str__(self):
return 'icmp-block name="%s"' % (self.name)


@dataclass(frozen=True)
class Rich_IcmpType(_Rich_Element):
def __init__(self, name):
self.name = name
"""This object only holds data and is read-only after init. It is also
hashable and can be used as a dictionary key."""

def __str__(self):
return 'icmp-type name="%s"' % (self.name)
name: str

def check(self, family=None):
def __post_init__(self):
if self.name is None or len(self.name) < 1:
raise FirewallError(errors.INVALID_ICMPTYPE, str(self.name))

def __str__(self):
return 'icmp-type name="%s"' % (self.name)


class Rich_Tcp_Mss_Clamp(_Rich_Element):
def __init__(self, value):
Expand Down

0 comments on commit 3a4f695

Please sign in to comment.