]> git.ipfire.org Git - network.git/commitdiff
ip-tunnel: Make --peer optional
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Sep 2018 12:10:41 +0000 (14:10 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Sep 2018 12:10:41 +0000 (14:10 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
man/network-zone-ip-tunnel.xml
src/hooks/zones/ip-tunnel

index cd3fa639deba3cff0b99bc743a522faa8a559499..a1cc2579b1a1951a838f571e44b846b7ce345bde 100644 (file)
                                                The address of the peer that terminates the remote
                                                end of this tunnel.
                                        </para>
+
+                                       <para>
+                                               If left empty, connections from any IP address will
+                                               be accepted.
+                                       </para>
                                </listitem>
                        </varlistentry>
 
index 43a9e712ab8e1f2f976e1145e19adb20a4956465..c9c73bab7472845538d16d66acee9199bf007a14 100644 (file)
@@ -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