###############################################################################
# #
# IPFire.org - A linux based firewall #
-# Copyright (C) 2010 Michael Tremer & Christian Schmidt #
+# Copyright (C) 2013 IPFire Network Development Team #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# #
###############################################################################
-. /lib/network/header-zone
+. /usr/lib/network/header-zone
-HOOK_SETTINGS="HOOK PROTOCOL USER SECRET SERVER TUNNEL_ID"
+HOOK_SETTINGS="HOOK PASSWORD PROTOCOL REQUIRE_TLS USERNAME SERVER TUNNEL_ID"
-USER=
-SECRET=
+USERNAME=
+PASSWORD=
SERVER="tic.sixxs.net"
PROTOCOL="tic"
TUNNEL_ID=
+REQUIRE_TLS="true"
-function _check() {
- assert isset USER
- assert isset SECRET
+function hook_check() {
+ assert isset USERNAME
+ assert isset PASSWORD
assert isset SERVER
assert isset PROTOCOL
+ assert isset REQUIRE_TLS
+
+ # Check if a supported protocol has been given.
+ if ! list_match "${PROTOCOL}" ${AICCU_SUPPORTED_PROTOCOLS}; then
+ log ERROR "This protocol is not supported by aiccu: ${PROTOCOL}"
+ log ERROR "Valid protocols are: ${AICCU_SUPPORTED_PROTOCOLS}"
+ return ${EXIT_ERROR}
+ fi
}
-function _parse_cmdline() {
+function hook_parse_cmdline() {
local value
while [ $# -gt 0 ]; do
case "$1" in
- --user=*)
- USER=$(cli_get_val ${1})
+ --username=*)
+ USERNAME="$(cli_get_val ${1})"
;;
- --secret=*)
- SECRET=$(cli_get_val ${1})
+ --password=*)
+ PASSWORD="$(cli_get_val ${1})"
;;
--server=*)
- SERVER=$(cli_get_val ${1})
+ SERVER="$(cli_get_val ${1})"
;;
--protocol=*)
- PROTOCOL=$(cli_get_val ${1})
+ PROTOCOL="$(cli_get_val ${1})"
;;
--tunnel-id=*)
- TUNNEL_ID=$(cli_get_val ${1})
+ TUNNEL_ID="$(cli_get_val ${1})"
+ ;;
+ --require-tls=*)
+ REQUIRE_TLS="$(cli_get_val ${1})"
+
+ if enabled val; then
+ REQUIRE_TLS="true"
+ else
+ REQUIRE_TLS="false"
+ fi
;;
*)
echo "Unknown option: $1" >&2
done
}
-function _up() {
+function hook_up() {
local zone=${1}
- shift
-
assert isset zone
- zone_config_read ${zone}
+ # Start aiccu on this zone.
+ aiccu_start ${zone}
- aiccu_start ${zone} \
- --server="${SERVER}" \
- --protocol="${PROTOCOL}" \
- --user="${USER}" \
- --secret="${SECRET}" \
- --tunnel-id="${TUNNEL_ID}"
-
- exit $?
+ exit ${EXIT_OK}
}
-function _down() {
+function hook_down() {
local zone=${1}
- shift
+ assert isset zone
+ # Stop aiccu on this zone.
aiccu_stop ${zone}
exit ${EXIT_OK}
}
-function _status() {
+function hook_status() {
local zone=${1}
assert isset zone
zone_config_read ${zone}
cli_headline 2 "Configuration"
- cli_print_fmt1 2 "User" "${USER}"
+ cli_print_fmt1 2 "User" "${USERNAME}"
cli_print_fmt1 2 "Secret" "<hidden>"
cli_space
cli_print_fmt1 2 "Server" "${SERVER}"
exit ${EXIT_OK}
}
-
-run $@