summaryrefslogtreecommitdiff
path: root/net/sslh/files/sslh.in
blob: 7722da39b29a18c3cce272fc4b43ee5ab2082a88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

# sslh startup script

# PROVIDE: sslh
# REQUIRE: LOGIN FILESYSTEMS ldconfig sshd
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service:
# sslh_enable="YES"
#
# You can fine tune other variables too:
# sslh_mode="fork | select"
# fork: stable but slow performance
# select: new but high performance
# sslh_fib: routing table number

sslh_precmd() {
	if command -v check_namevarlist > /dev/null 2>&1; then
		check_namevarlist fib && return 0
	fi
	sysctl net.fibs > /dev/null 2>&1 || return 0

	sslh_fib=${sslh_fib:-"NONE"}
	case "$sslh_fib" in
	[Nn][Oo][Nn][Ee])
		;;
	*)
		command="setfib -F ${sslh_fib} ${command}"
		;;
	esac
}

. /etc/rc.subr

name="sslh"
rcvar=sslh_enable

start_precmd="sslh_precmd"

load_rc_config $name
sslh_enable=${sslh_enable:-"NO"}
sslh_mode=${sslh_mode:-"fork"}

required_files="%%PREFIX%%/etc/${name}.conf"

for value in listening openvpntarget sshtarget sshtimeout ssltarget \
    tinctarget xmpptarget; do
	eval "[ -n \"\${sslh_${value}}\" ]" && \
	    warn "${name}_${value} no longer used: configuration file available"
done

command="%%PREFIX%%/sbin/${name}-${sslh_mode}"
command_args="-F%%PREFIX%%/etc/${name}.conf"

run_rc_command "$1"