blob: 8d7d1f185d8586155429534c18ca4b0838c20035 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/sh /etc/rc.common
# Copyright (C) 2009-2017 OpenWrt.org
START=95
# XXX: pid-files are useless because sslh forks after creating them
SERVICE_USE_PID=
start_instance() {
local section="$1"
# check if section is enabled (default)
local enable
config_get_bool enable "${section}" 'enable' '0'
[ ${enable} -gt 0 ] || return 1
local args=""
local val
# A) listen parameter
config_get vals "${section}" listen
[ -n "${vals}" ] && for val in $vals; do append args "-p${val}"; done
# B) ssh parameter
config_get val "${section}" ssh
[ -n "${val}" ] && append args "--ssh ${val}"
# C) tls parameter
config_get val "${section}" tls
[ -n "${val}" ] && append args "--tls ${val}"
# D) openvpn parameter
config_get val "${section}" openvpn
[ -n "${val}" ] && append args "--openvpn ${val}"
# E) tinc parameter
config_get val "${section}" tinc
[ -n "${val}" ] && append args "--tinc ${val}"
# F) xmpp parameter
config_get val "${section}" xmpp
[ -n "${val}" ] && append args "--xmpp ${val}"
# G) timeout (before a connection is considered to be SSH)
config_get val "${section}" timeout
[ -n "${val}" ] && append args "-t ${val}"
# H) verbose parameter
local verbosed
config_get_bool verbosed "${section}" verbose 0
[ "${verbosed}" -ne 0 ] && append args "-v"
# I) sslh config file (cmd line args override file settings)
config_get val "${section}" configfile
[ -n "${val}" ] && append args "-F${val}"
# J) http parameter
config_get val "${section}" http
[ -n "${val}" ] && append args "--http ${val}"
# K) transparent parameter
config_get_bool val "${section}" transparent 0
[ "${val}" -ne 0 ] && append args "--transparent"
# Defaults were removed for --user and --pidfile options
# in sslh 1.11; Define them here instead.
append args "--user nobody"
append args "--pidfile /var/run/sslh.pid"
# XXX: allow more that one instance to run simultaneously
SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
service_start /usr/sbin/sslh ${args}
}
start() {
config_load 'sslh'
config_foreach start_instance 'sslh'
}
stop() {
service_stop /usr/sbin/sslh
}
|