#!/bin/bash

# Alias: Restrict livestatus port to IP addresses
# Menu: Distributed Monitoring
# Description:
#  If Livestatus is configured to listen on a TCP port, you
#  can configure the IP addresses that are allowed to
#  connect to livestatus here. The setting "0.0.0.0 ::/0" makes the
#  port available to all IPv4 and IPv6 clients,

case "$1" in
    default)
        echo "0.0.0.0 ::/0"
    ;;
    choices)
        echo "@{IP_ADDRESS_LIST}"
    ;;
    set)
        sed -ri "s@#?([[:space:]]*only_from[[:space:]]*=[[:space:]]*)(.*)@\1$2@" $OMD_ROOT/etc/mk-livestatus/xinetd.conf
    ;;
    depends)
        [ "$CONFIG_CORE" != none -a "$CONFIG_LIVESTATUS_TCP" = on ]
    ;;
esac
