Warning the user when using a loopback IP as forwarder

Changing the --forwarder option to accept a loopback IP.
Previously, an error would be raised, now we just show a
warning message.

Fixes: https://pagure.io/freeipa/issue/5801
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Felipe Barreto
2017-10-23 09:45:56 -02:00
parent b84e8be5ac
commit 405da071d1
5 changed files with 37 additions and 8 deletions

View File

@@ -244,6 +244,25 @@ class CheckedIPAddress(UnsafeIPAddress):
self._net = ifnet
class CheckedIPAddressLoopback(CheckedIPAddress):
"""IPv4 or IPv6 address with additional constraints with
possibility to use a loopback IP.
Reserved or link-local addresses are never accepted.
"""
def __init__(self, addr, parse_netmask=True, allow_multicast=False):
super(CheckedIPAddressLoopback, self).__init__(
addr, parse_netmask=parse_netmask,
allow_multicast=allow_multicast,
allow_loopback=True)
if self.is_loopback():
# print is being used instead of a logger, because at this
# moment, in execution process, there is no logger configured
print("WARNING: You are using a loopback IP: {}".format(addr),
file=sys.stderr)
def valid_ip(addr):
return netaddr.valid_ipv4(addr) or netaddr.valid_ipv6(addr)