From: Michael Tremer Date: Wed, 19 Sep 2018 12:10:41 +0000 (+0200) Subject: ip-tunnel: Make --peer optional X-Git-Tag: 010~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfaa4f61a2642ecac62a106b8b6f54ec059b67fc;p=network.git ip-tunnel: Make --peer optional Signed-off-by: Michael Tremer --- diff --git a/man/network-zone-ip-tunnel.xml b/man/network-zone-ip-tunnel.xml index cd3fa639..a1cc2579 100644 --- a/man/network-zone-ip-tunnel.xml +++ b/man/network-zone-ip-tunnel.xml @@ -78,6 +78,11 @@ The address of the peer that terminates the remote end of this tunnel. + + + If left empty, connections from any IP address will + be accepted. + diff --git a/src/hooks/zones/ip-tunnel b/src/hooks/zones/ip-tunnel index 43a9e712..c9c73bab 100644 --- a/src/hooks/zones/ip-tunnel +++ b/src/hooks/zones/ip-tunnel @@ -80,14 +80,8 @@ hook_parse_cmdline() { shift done - # PEER must be set - if ! isset PEER; then - error "Peer is not set" - return ${EXIT_ERROR} - fi - - # PEER must be a valid IP address - if ! ip_is_valid "${PEER}"; then + # If PEER is set, it must be a valid IP address + if isset PEER && ! ip_is_valid "${PEER}"; then error "Peer ${PEER} is not a valid IP address" return ${EXIT_ERROR} fi @@ -163,11 +157,16 @@ hook_status() { exit ${EXIT_ERROR} fi - cli_headline 2 "Configuration" - cli_print_fmt1 2 "Mode" "$(ip_tunnel_protocol_to_name "${MODE}")" - cli_print_fmt1 2 "Peer" "${PEER}" - if isset LOCAL_ADDRESS; then - cli_print_fmt1 2 "Local Address" "${LOCAL_ADDRESS}" + cli_print_fmt1 1 "Mode" "$(ip_tunnel_protocol_to_name "${MODE}")" + + if isset PEER || isset LOCAL_ADDRESS; then + if isset PEER; then + cli_print_fmt1 1 "Peer" "${PEER}" + fi + + if isset LOCAL_ADDRESS; then + cli_print_fmt1 1 "Local Address" "${LOCAL_ADDRESS}" + fi fi cli_space