2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2017 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 IPSEC_CONNECTION_CONFIG_SETTINGS
="\
40 IPSEC_DEFAULT_AUTH_MODE
="PSK"
41 IPSEC_DEFAULT_DPD_ACTION
="restart"
42 IPSEC_DEFAULT_DPD_DELAY
="30"
43 IPSEC_DEFAULT_DPD_TIMEOUT
="120"
44 IPSEC_DEFAULT_ENABLED
="true"
45 IPSEC_DEFAULT_INACTIVITY_TIMEOUT
="0"
46 IPSEC_DEFAULT_MODE
="tunnel"
47 IPSEC_DEFAULT_SECURITY_POLICY
="system"
48 IPSEC_DEFAULT_START_ACTION
="on-demand"
50 IPSEC_VALID_MODES
="gre-transport tunnel vti"
51 IPSEC_VALID_AUTH_MODES
="PSK"
59 cli_ipsec_connection $@
62 error
"Unrecognized argument: ${action}"
68 cli_ipsec_connection
() {
69 if ipsec_connection_exists
${1}; then
76 authentication|down|disable|dpd|
enable|inactivity_timeout|
local|mode|peer|remote|security_policy|start_action|up
)
77 ipsec_connection_
${key} ${connection} $@
80 cli_ipsec_connection_show
"${connection}"
84 error
"Unrecognized argument: ${key}"
94 ipsec_connection_new $@
97 ipsec_connection_destroy $@
100 if [ -n "${action}" ]; then
101 error
"Unrecognized argument: '${action}'"
109 cli_ipsec_connection_show
() {
110 local connection
="${1}"
112 # Read the config settings
113 local ${IPSEC_CONNECTION_CONFIG_SETTINGS}
114 if ! ipsec_connection_read_config
"${connection}"; then
115 error
"Could not read the connection configuration"
119 cli_headline
0 "IPsec VPN Connection: ${connection}"
124 cli_print_fmt1
1 "Peer" "${PEER}"
128 cli_print_fmt1
1 "Security Policy" "${SECURITY_POLICY-${IPSEC_DEFAULT_SECURITY_POLICY}}"
131 cli_headline
2 "Authentication"
132 case "${AUTH_MODE^^}" in
134 cli_print_fmt1
2 "Mode" "Pre-Shared-Key"
137 cli_print_fmt1
2 "Pre-Shared-Key" "****"
139 cli_print_fmt1
2 "Pre-Shared-Key" "- is not set -"
149 for i
in LOCAL REMOTE
; do
152 cli_headline
2 "Local"
155 cli_headline
2 "Remote"
159 local id_var
="${i}_ID"
160 if [ -n "${!id_var}" ]; then
161 cli_print_fmt1
2 "ID" "${!id_var}"
164 local prefix_var
="${i}_PREFIX"
165 if isset
${prefix_var}; then
166 cli_headline
3 "Prefix(es)"
169 for prefix
in ${!prefix_var}; do
170 cli_print_fmt1
3 "${prefix}"
177 cli_headline
2 "Misc."
181 cli_print_fmt1
2 "Transport Mode" "GRE Transport"
184 cli_print_fmt1
2 "Transport Mode" "Tunnel"
187 cli_print_fmt1
2 "Transport Mode" "Virtual Tunnel Interface"
190 cli_print_fmt1
2 "Transport Mode" "- Unknown -"
195 if isset INACTIVITY_TIMEOUT
&& [ ${INACTIVITY_TIMEOUT} -gt 0 ]; then
196 cli_print_fmt1
2 "Inactivity Timeout" "$(format_time ${INACTIVITY_TIMEOUT})"
203 ipsec_connection_disable
() {
204 local connection
=${1}
206 if ! ipsec_connection_write_config_key
"${connection}" "ENABLED" "false"; then
207 log ERROR
"Could not write configuration settings"
211 ipsec_reload
${connection}
214 ipsec_connection_enable
() {
215 local connection
=${1}
217 if ! ipsec_connection_write_config_key
"${connection}" "ENABLED" "true"; then
218 log ERROR
"Could not write configuration settings"
222 ipsec_reload
"${connection}"
225 # This function writes all values to a via ${connection} specificated VPN IPsec configuration file
226 ipsec_connection_write_config
() {
229 local connection
="${1}"
231 if ! ipsec_connection_exists
"${connection}"; then
232 log ERROR
"No such VPN IPsec connection: ${connection}"
236 local path
="${NETWORK_IPSEC_CONNS_DIR}/${connection}/settings"
238 if ! settings_write
"${path}" ${IPSEC_CONNECTION_CONFIG_SETTINGS}; then
239 log ERROR
"Could not write configuration settings for VPN IPsec connection ${connection}"
243 ipsec_reload
${connection}
246 # This funtion writes the value for one key to a via ${connection} specificated VPN IPsec connection configuration file
247 ipsec_connection_write_config_key
() {
250 local connection
=${1}
256 if ! ipsec_connection_exists
"${connection}"; then
257 log ERROR
"No such VPN ipsec connection: ${connection}"
261 log DEBUG
"Set '${key}' to new value '${value}' in VPN ipsec connection '${connection}'"
263 local ${IPSEC_CONNECTION_CONFIG_SETTINGS}
265 # Read the config settings
266 if ! ipsec_connection_read_config
"${connection}"; then
270 # Set the key to a new value
271 assign
"${key}" "${value}"
273 if ! ipsec_connection_write_config
"${connection}"; then
280 # Reads one or more keys out of a settings file or all if no key is provided.
281 ipsec_connection_read_config
() {
284 local connection
="${1}"
287 if ! ipsec_connection_exists
"${connection}"; then
288 log ERROR
"No such VPN IPsec connection : ${connection}"
294 if [ $# -eq 0 ] && [ -n "${IPSEC_CONNECTION_CONFIG_SETTINGS}" ]; then
295 list_append args
${IPSEC_CONNECTION_CONFIG_SETTINGS}
300 local path
="${NETWORK_IPSEC_CONNS_DIR}/${connection}/settings"
302 if ! settings_read
"${path}" ${args}; then
303 log ERROR
"Could not read settings for VPN IPsec connection ${connection}"
308 # This function checks if a vpn ipsec connection exists
309 # Returns True when yes and false when not
310 ipsec_connection_exists
() {
313 local connection
=${1}
315 local path
="${NETWORK_IPSEC_CONNS_DIR}/${connection}"
317 [ -d "${path}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
320 ipsec_strongswan_load() {
321 if ! cmd swanctl --load-all; then
322 log ERROR "Could not reload strongswan config
"
327 # Reloads the connection after config changes
329 local connection=${1}
333 if ! ipsec_connection_read_config "${connection}" "ENABLED
"; then
334 log ERROR "Could not
read configuration
for IPsec connection
${connection}"
338 if enabled ${ENABLED}; then
339 if ! ipsec_connection_to_strongswan ${connection}; then
340 log ERROR "Could not generate strongswan config
for ${connnection}"
344 unlink "${NETWORK_IPSEC_SWANCTL_CONNECTIONS_DIR}/${connection}.conf
"
347 ipsec_strongswan_load
350 # Handle the cli after authentification
351 ipsec_connection_authentication() {
352 if [ ! $# -gt 1 ]; then
353 log ERROR "Not enough arguments
"
357 local connection=${1}
363 ipsec_connection_authentication_mode "${connection}" $@
366 ipsec_connection_authentication_psk "${connection}" $@
369 log ERROR "Unrecognized argument
: ${cmd}"
375 # Set the authentification mode
376 ipsec_connection_authentication_mode() {
377 if [ ! $# -eq 2 ]; then
378 log ERROR "Not enough arguments
"
381 local connection=${1}
384 if ! isoneof mode ${IPSEC_VALID_AUTH_MODES}; then
385 log ERROR "Auth mode
'${mode}' is invalid
"
389 if ! ipsec_connection_write_config_key "${connection}" "AUTH_MODE
" ${mode^^}; then
390 log ERROR "Could not
write configuration settings
"
396 ipsec_connection_authentication_psk() {
397 if [ ! $# -eq 2 ]; then
398 log ERROR "Not enough arguments
"
402 local connection=${1}
407 if [ ${length} -lt 4 ]; then
408 error "The PSK must be longer than four characters
"
412 if [ ${length} -gt 128 ]; then
413 error "The PSK cannot be longer than
128 characters
"
417 if ! ipsec_connection_write_config_key "${connection}" "PSK
" "${psk}"; then
418 log ERROR "Could not
write configuration settings
"
425 ipsec_connection_up() {
426 local connection="${1}"
428 if ! ipsec_connection_exists "${connection}"; then
429 error "No such VPN IPsec connection
: ${connection}"
433 cmd swanctl --initiate --child "${connection}"
436 ipsec_connection_down() {
437 local connection="${1}"
439 if ! ipsec_connection_exists "${connection}"; then
440 error "No such VPN IPsec connection
: ${connection}"
444 cmd swanctl --terminate --ike "${connection}"
447 # Handle the cli after authentification
448 ipsec_connection_dpd() {
449 if [ ! $# -gt 1 ]; then
450 log ERROR "Not enough arguments
"
454 local connection=${1}
460 ipsec_connection_dpd_action "${connection}" $@
463 ipsec_connection_dpd_delay "${connection}" $@
466 ipsec_connection_dpd_timeout "${connection}" $@
469 log ERROR "Unrecognized argument
: ${cmd}"
475 # Set the default dpd action
476 ipsec_connection_dpd_action() {
477 if [ ! $# -eq 2 ]; then
478 log ERROR "Not enough arguments
"
481 local connection=${1}
484 if ! isoneof action "restart
" "clear"; then
485 log ERROR "dpd action
'${action}' is invalid
"
489 if ! ipsec_connection_write_config_key "${connection}" "DPD_ACTION
" ${action}; then
490 log ERROR "Could not
write configuration settings
"
496 ipsec_connection_dpd_delay() {
497 if [ ! $# -ge 2 ]; then
498 log ERROR "Not enough arguments
"
502 local connection=${1}
506 if ! isinteger value; then
507 value=$(parse_time $@)
508 if [ ! $? -eq 0 ]; then
509 log ERROR "Parsing the passed
time was not sucessful please check the passed values.
"
514 if [ ${value} -lt 0 ]; then
515 log ERROR "The passed
time value must be
in the
sum greater or equal zero seconds.
"
519 if ! ipsec_connection_write_config_key "${connection}" "DPD_DELAY
" ${value}; then
520 log ERROR "Could not
write configuration settings
"
527 # Set the dpd timeout
528 ipsec_connection_dpd_timeout() {
529 if [ ! $# -ge 2 ]; then
530 log ERROR "Not enough arguments
"
534 local connection=${1}
538 if ! isinteger value; then
539 value=$(parse_time $@)
540 if [ ! $? -eq 0 ]; then
541 log ERROR "Parsing the passed
time was not sucessful please check the passed values.
"
546 if [ ${value} -le 0 ]; then
547 log ERROR "The passed
time value must be
in the
sum greater or equal zero seconds.
"
551 if ! ipsec_connection_write_config_key "${connection}" "DPD_TIMEOUT
" ${value}; then
552 log ERROR "Could not
write configuration settings
"
559 # Handle the cli after local
560 ipsec_connection_local() {
561 if [ ! $# -ge 2 ]; then
562 log ERROR "Not enough arguments
"
566 local connection=${1}
572 ipsec_connection_local_address "${connection}" $@
575 ipsec_connection_id "${connection}" "LOCAL
" $@
578 ipsec_connection_prefix "${connection}" "LOCAL
" $@
581 log ERROR "Unrecognized argument
: ${cmd}"
589 # Set the connection mode
590 ipsec_connection_mode() {
591 if [ ! $# -eq 2 ]; then
592 log ERROR "Not enough arguments
"
595 local connection=${1}
598 if ! isoneof mode ${IPSEC_VALID_MODES}; then
599 log ERROR "Mode
'${mode}' is invalid
"
603 if ! ipsec_connection_write_config_key "${connection}" "MODE
" ${mode}; then
604 log ERROR "Could not
write configuration settings
"
611 # Set the local address
612 ipsec_connection_local_address() {
613 if [ ! $# -eq 2 ]; then
614 log ERROR "Not enough arguments
"
617 local connection=${1}
618 local local_address=${2}
620 if ! ipsec_connection_check_peer ${local_address}; then
621 log ERROR "Local address
'${local_address}' is invalid
"
625 if ! ipsec_connection_write_config_key "${connection}" "LOCAL_ADDRESS
" ${local_address}; then
626 log ERROR "Could not
write configuration settings
"
633 # Set the peer to connect to
634 ipsec_connection_peer() {
635 if [ ! $# -eq 2 ]; then
636 log ERROR "Not enough arguments
"
639 local connection=${1}
642 if ! ipsec_connection_check_peer ${peer}; then
643 log ERROR "Peer
'${peer}' is invalid
"
647 if ! ipsec_connection_write_config_key "${connection}" "PEER
" ${peer}; then
648 log ERROR "Could not
write configuration settings
"
655 #Set the local or remote id
656 ipsec_connection_id() {
657 if [ ! $# -eq 3 ]; then
658 log ERROR "Not enough arguments
"
661 local connection=${1}
665 if ! ipsec_connection_check_id ${id}; then
666 log ERROR "Id
'${id}' is invalid
"
670 if ! ipsec_connection_write_config_key "${connection}" "${type}_ID" ${id}; then
671 log ERROR
"Could not write configuration settings"
678 # Set the local or remote prefix
679 ipsec_connection_prefix
() {
680 if [ ! $# -ge 3 ]; then
681 log ERROR
"Not enough arguments"
684 local connection
=${1}
688 local _prefix
="${type}_PREFIX"
690 if ! ipsec_connection_read_config
"${connection}" "${_prefix}"; then
694 # Remove duplicated entries to proceed the list safely
695 assign
"${_prefix}" "$(list_unique ${!_prefix} )"
698 local prefixes_removed
701 while [ $# -gt 0 ]; do
706 list_append prefixes_added
"${arg:1}"
709 list_append prefixes_removed
"${arg:1}"
712 list_append prefixes_set
"${arg}"
715 error
"Invalid argument: ${arg}"
722 # Check if the user is trying a mixed operation
723 if ! list_is_empty prefixes_set
&& (! list_is_empty prefixes_added ||
! list_is_empty prefixes_removed
); then
724 error
"You cannot reset the prefix list and add or remove prefixes at the same time"
728 # Set new prefix list
729 if ! list_is_empty prefixes_set
; then
730 # Check if all prefixes are valid
732 for prefix
in ${prefixes_set}; do
733 if ! ip_net_is_valid
${prefix}; then
734 error
"Unsupported prefix: ${prefix}"
739 assign
"${_prefix}" "${prefixes_set}"
741 # Perform incremental updates
745 # Perform all removals
746 for prefix
in ${prefixes_removed}; do
747 if ! list_remove
"${_prefix}" ${prefix}; then
748 warning
"${prefix} was not on the list and could not be removed"
753 for prefix
in ${prefixes_added}; do
754 if ip_net_is_valid
${prefix}; then
755 if ! list_append_unique
"${_prefix}" ${prefix}; then
756 warning
"${prefix} is already on the prefix list"
759 warning
"${prefix} is not a valid IP network and could not be added"
764 # Check if the list contain at least one valid prefix
765 if list_is_empty
${_prefix}; then
766 error
"Cannot save an empty prefix list"
771 if ! ipsec_connection_write_config_key
"${connection}" "${_prefix}" ${!_prefix}; then
772 log ERROR "Could not
write configuration settings
"
778 # Handle the cli after remote
779 ipsec_connection_remote() {
780 if [ ! $# -ge 2 ]; then
781 log ERROR "Not enough arguments
"
785 local connection=${1}
791 ipsec_connection_id "${connection}" "REMOTE
" $@
795 ipsec_connection_prefix "${connection}" "REMOTE
" $@
798 log ERROR "Unrecognized argument
: ${cmd}"
806 # Set the inactivity timeout
807 ipsec_connection_inactivity_timeout() {
808 if [ ! $# -ge 2 ]; then
809 log ERROR "Not enough arguments
"
813 local connection=${1}
817 if ! isinteger value; then
818 value=$(parse_time $@)
819 if [ ! $? -eq 0 ]; then
820 log ERROR "Parsing the passed
time was not sucessful please check the passed values.
"
825 if [ ${value} -le 0 ]; then
826 log ERROR "The passed
time value must be
in the
sum greater zero seconds.
"
830 if ! ipsec_connection_write_config_key "${connection}" "INACTIVITY_TIMEOUT
" ${value}; then
831 log ERROR "Could not
write configuration settings
"
838 # Set the default start action
839 ipsec_connection_start_action() {
840 if [ ! $# -eq 2 ]; then
841 log ERROR "Not enough arguments
"
844 local connection=${1}
847 if ! isoneof action "on-demand
" "always-on
"; then
848 log ERROR "Start action
'${action}' is invalid
"
852 if ! ipsec_connection_write_config_key "${connection}" "START_ACTION
" ${action}; then
853 log ERROR "Could not
write configuration settings
"
858 # Set the security policy to use
859 ipsec_connection_security_policy() {
860 if [ ! $# -eq 2 ]; then
861 log ERROR "Not enough arguments
"
864 local connection=${1}
865 local security_policy=${2}
867 if ! vpn_security_policy_exists ${security_policy}; then
868 log ERROR "No such vpn security policy
'${security_policy}'"
872 if ! ipsec_connection_write_config_key "${connection}" "SECURITY_POLICY
" ${security_policy}; then
873 log ERROR "Could not
write configuration settings
"
878 # Check if a id is valid
879 ipsec_connection_check_id() {
883 if [[ ${id} =~ ^@[[:alnum:]]+$ ]] || ip_is_valid ${id}; then
890 # Checks if a peer is valid
891 ipsec_connection_check_peer() {
895 # TODO Accept also FQDNs
896 if ip_is_valid ${peer}; then
903 # This function checks if a VPN IPsec connection name is valid
904 # Allowed are only A-Za-z0-9
905 ipsec_connection_check_name() {
908 local connection=${1}
910 [[ "${connection}" =~ [^[:alnum:]$] ]]
913 # Function that creates one VPN IPsec connection
914 ipsec_connection_new() {
915 if [ $# -gt 1 ]; then
916 error "Too many arguments
"
920 local connection="${1}"
921 if ! isset connection; then
922 error "Please provide a connection name
"
926 # Check for duplicates
927 if ipsec_connection_exists "${connection}"; then
928 error "The VPN IPsec connection
${connection} already exists
"
932 # Check if the name of the connection is valid
933 if ipsec_connection_check_name "${connection}"; then
934 error "'${connection}' contains illegal characters
"
938 log DEBUG "Creating VPN IPsec connection
${connection}"
940 if ! mkdir -p "${NETWORK_IPSEC_CONNS_DIR}/${connection}"; then
941 log ERROR "Could not create config directory
for ${connection}"
945 local ${IPSEC_CONNECTION_CONFIG_SETTINGS}
947 AUTH_MODE=${IPSEC_DEFAULT_AUTH_MODE}
948 DPD_ACTION=${IPSEC_DEFAULT_DPD_ACTION}
949 DPD_DELAY=${IPSEC_DEFAULT_DPD_DELAY}
950 DPD_TIMEOUT=${IPSEC_DEFAULT_DPD_TIMEOUT}
951 ENABLED=${IPSEC_DEFAULT_ENABLED}
952 MODE=${IPSEC_DEFAULT_MODE}
953 START_ACTION=${IPSEC_DEFAULT_START_ACTION}
955 INACTIVITY_TIMEOUT=${IPSEC_DEFAULT_INACTIVITY_TIMEOUT}
956 SECURITY_POLICY=${IPSEC_DEFAULT_SECURITY_POLICY}
958 if ! ipsec_connection_write_config "${connection}"; then
959 log ERROR "Could not
write new config
file"
964 # Function that deletes based on the passed parameters one ore more vpn security policies
965 ipsec_connection_destroy() {
967 for connection in $@; do
968 if ! ipsec_connection_exists "${connection}"; then
969 log ERROR "The VPN IPsec connection
${connection} does not exist.
"
973 log DEBUG "Deleting VPN IPsec connection
${connection}"
974 if ! rm -rf "${NETWORK_IPSEC_CONNS_DIR}/${connection}"; then
975 log ERROR "Deleting the VPN IPsec connection
${connection} was not sucessful
"
981 # List all ipsec connections
982 ipsec_list_connections() {
984 for connection in ${NETWORK_IPSEC_CONNS_DIR}/*; do
985 [ -d ${connection} ] || continue
986 basename ${connection}
990 ipsec_connection_to_strongswan() {
991 local connection="${1}"
993 # Read the config settings
994 local ${IPSEC_CONNECTION_CONFIG_SETTINGS}
995 if ! ipsec_connection_read_config "${connection}"; then
996 error "Could not
read the connection
${connection}"
1000 local path="${NETWORK_IPSEC_SWANCTL_CONNECTIONS_DIR}/${connection}.conf
"
1003 # Write the connection section
1004 _ipsec_connection_to_strongswan_connection "${connection}"
1006 # Write the secrets section
1007 _ipsec_connection_to_strongswan_secrets "${connection}"
1012 _ipsec_connection_to_strongswan_connection() {
1013 local connection="${1}"
1015 # Read the security policy
1016 local ${VPN_SECURITY_POLICIES_CONFIG_SETTINGS}
1017 if ! vpn_security_policies_read_config "${SECURITY_POLICY}"; then
1018 return ${EXIT_ERROR}
1023 if isset DPD_DELAY && isinteger DPD_DELAY && [ ${DPD_DELAY} -gt 0 ]; then
1027 print_indent 0 "connections
{"
1028 print_indent 1 "${connection} {"
1031 print_indent 2 "# IKE Version"
1032 case "${KEY_EXCHANGE^^}" in
1034 print_indent
2 "version = 1"
1037 # Fall back to IKEv2 for any random values
1039 print_indent
2 "version = 2"
1045 print_indent
2 "# Local Address"
1046 if isset LOCAL_ADDRESS
; then
1047 print_indent
2 "local_addrs = ${LOCAL_ADDRESS}"
1049 print_indent
2 "local_addrs = %any"
1054 print_indent
2 "# Remote Address"
1056 print_indent
2 "remote_addrs = ${PEER}"
1058 print_indent
2 "remote_addrs = %any"
1063 print_indent
2 "# IKE Proposals"
1064 print_indent
2 "proposals = $(vpn_security_policies_make_ike_proposal ${SECURITY_POLICY})"
1068 if enabled dpd
; then
1069 print_indent
2 "# Dead Peer Detection"
1070 print_indent
2 "dpd_delay = ${DPD_DELAY}"
1072 if isset DPD_TIMEOUT
; then
1073 print_indent
2 "dpd_timeout = ${DPD_TIMEOUT}"
1080 print_indent
2 "# Fragmentation"
1081 print_indent
2 "fragmentation = yes"
1085 print_indent
2 "local {"
1088 if isset LOCAL_ID
; then
1089 print_indent
3 "id = ${LOCAL_ID}"
1093 case "${AUTH_MODE}" in
1095 print_indent
3 "auth = psk"
1103 print_indent
2 "remote {"
1106 if isset REMOTE_ID
; then
1107 print_indent
3 "id = ${REMOTE_ID}"
1111 case "${AUTH_MODE}" in
1113 print_indent
3 "auth = psk"
1122 print_indent
2 "children {"
1123 print_indent
3 "${connection} {"
1125 print_indent
4 "# ESP Proposals"
1126 print_indent
4 "esp_proposals = $(vpn_security_policies_make_esp_proposal ${SECURITY_POLICY})"
1133 print_indent
4 "local_ts = dynamic[gre]"
1134 print_indent
4 "remote_ts = dynamic[gre]"
1138 if isset LOCAL_PREFIX
; then
1139 print_indent
4 "local_ts = $(list_join LOCAL_PREFIX ,)"
1141 print_indent
4 "local_ts = dynamic"
1145 if isset REMOTE_PREFIX
; then
1146 print_indent
4 "remote_ts = $(list_join REMOTE_PREFIX ,)"
1148 print_indent
4 "remote_ts = dynamic"
1155 print_indent
4 "# Netfilter Marks"
1156 print_indent
4 "mark_in = %unique"
1157 print_indent
4 "mark_out = %unique"
1160 # Dead Peer Detection
1161 if enabled dpd
; then
1162 print_indent
4 "# Dead Peer Detection"
1163 print_indent
4 "dpd_action = ${DPD_ACTION}"
1168 if isset LIFETIME
; then
1169 print_indent
4 "# Rekey Time"
1170 print_indent
4 "rekey_time = ${LIFETIME}"
1175 print_indent
4 "updown = ${NETWORK_HELPERS_DIR}/ipsec-updown"
1179 print_indent
4 "# Mode"
1182 print_indent
4 "mode = transport"
1185 print_indent
4 "mode = tunnel"
1191 print_indent
4 "# Compression"
1192 if enabled COMPRESSION
; then
1193 print_indent
4 "ipcomp = yes"
1195 print_indent
4 "ipcomp = no"
1199 # Inactivity Timeout
1200 if isset INACTIVITY_TIMEOUT
; then
1201 print_indent
4 "# Inactivity Timeout"
1202 print_indent
4 "inactivity = ${INACTIVITY_TIMEOUT}"
1207 print_indent
4 "# Start Action"
1208 case "${START_ACTION}" in
1210 print_indent
4 "start_action = trap"
1211 print_indent
4 "close_action = trap"
1214 print_indent
4 "start_action = none"
1215 print_indent
4 "close_action = none"
1218 print_indent
4 "start_action = start"
1219 print_indent
4 "close_action = start"
1233 _ipsec_connection_to_strongswan_secrets
() {
1234 local connection
="${1}"
1236 print_indent
0 "secrets {"
1238 case "${AUTH_MODE}" in
1240 print_indent
1 "ike {"
1243 print_indent
2 "secret = ${PSK}"
1246 if isset REMOTE_ID
; then
1247 print_indent
2 "id = ${REMOTE_ID}"