mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Allow broadcast ip addresses
Currently environments may use prefix /31 on point-to-point connections what makes IPA validators to fail. IPA should not care if IP address is broadcast or not. In some cases (when prefix is not specified) IPA cannot decide properly if broadcast address is really broadcast. This commit allows usage of broadcast addresses in: * host plugin * dns plugin * server-installer * client-installer https://fedorahosted.org/freeipa/ticket/5814 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
committed by
David Kupka
parent
00e747226f
commit
a6ab515add
@@ -132,8 +132,7 @@ class CheckedIPAddress(UnsafeIPAddress):
|
||||
Reserved or link-local addresses are never accepted.
|
||||
"""
|
||||
def __init__(self, addr, match_local=False, parse_netmask=True,
|
||||
allow_loopback=False, allow_broadcast=False,
|
||||
allow_multicast=False):
|
||||
allow_loopback=False, allow_multicast=False):
|
||||
|
||||
super(CheckedIPAddress, self).__init__(addr)
|
||||
if isinstance(addr, CheckedIPAddress):
|
||||
@@ -199,15 +198,14 @@ class CheckedIPAddress(UnsafeIPAddress):
|
||||
elif self.version == 6:
|
||||
self._net = netaddr.IPNetwork(str(self) + '/64')
|
||||
|
||||
if not allow_broadcast and (self.version == 4 and
|
||||
self == self._net.broadcast):
|
||||
raise ValueError("cannot use broadcast IP address {}".format(addr))
|
||||
|
||||
self.prefixlen = self._net.prefixlen
|
||||
|
||||
def is_network_addr(self):
|
||||
return self == self._net.network
|
||||
|
||||
def is_broadcast_addr(self):
|
||||
return self.version == 4 and self == self._net.broadcast
|
||||
|
||||
|
||||
def valid_ip(addr):
|
||||
return netaddr.valid_ipv4(addr) or netaddr.valid_ipv6(addr)
|
||||
|
||||
@@ -55,8 +55,10 @@ def test_ip_address():
|
||||
('241.1.2.3',),
|
||||
('169.254.1.2',),
|
||||
('10.11.12.0/24', (10, 11, 12, 0), 24),
|
||||
('10.0.0.255', (10, 0, 0, 255), 8),
|
||||
('224.5.6.7',),
|
||||
('10.11.12.255/24',),
|
||||
('10.11.12.255/24', (10, 11, 12, 255), 24),
|
||||
('255.255.255.255',),
|
||||
|
||||
('::/0',),
|
||||
('2001::1', (0x2001, 0, 0, 0, 0, 0, 0, 1), 64),
|
||||
|
||||
Reference in New Issue
Block a user