You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.9 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2017 OpenWrt.org
  3. START=95
  4. # XXX: pid-files are useless because sslh forks after creating them
  5. SERVICE_USE_PID=
  6. start_instance() {
  7. local section="$1"
  8. # check if section is enabled (default)
  9. local enable
  10. config_get_bool enable "${section}" 'enable' '0'
  11. [ ${enable} -gt 0 ] || return 1
  12. local args=""
  13. local val
  14. # A) listen parameter
  15. config_get vals "${section}" listen
  16. [ -n "${vals}" ] && for val in $vals; do append args "-p${val}"; done
  17. # B) ssh parameter
  18. config_get val "${section}" ssh
  19. [ -n "${val}" ] && append args "--ssh ${val}"
  20. # C) ssl parameter
  21. config_get val "${section}" ssl
  22. [ -n "${val}" ] && append args "--ssl ${val}"
  23. # D) openvpn parameter
  24. config_get val "${section}" openvpn
  25. [ -n "${val}" ] && append args "--openvpn ${val}"
  26. # E) tinc parameter
  27. config_get val "${section}" tinc
  28. [ -n "${val}" ] && append args "--tinc ${val}"
  29. # F) xmpp parameter
  30. config_get val "${section}" xmpp
  31. [ -n "${val}" ] && append args "--xmpp ${val}"
  32. # G) timeout (before a connection is considered to be SSH)
  33. config_get val "${section}" timeout
  34. [ -n "${val}" ] && append args "-t ${val}"
  35. # H) verbose parameter
  36. local verbosed
  37. config_get_bool verbosed "${section}" verbose 0
  38. [ "${verbosed}" -ne 0 ] && append args "-v"
  39. # I) sslh config file (cmd line args override file settings)
  40. config_get val "${section}" configfile
  41. [ -n "${val}" ] && append args "-F${val}"
  42. # J) http parameter
  43. config_get val "${section}" http
  44. [ -n "${val}" ] && append args "--http ${val}"
  45. # Defaults were removed for --user and --pidfile options
  46. # in sslh 1.11; Define them here instead.
  47. append args "--user nobody"
  48. append args "--pidfile /var/run/sslh.pid"
  49. # XXX: allow more that one instance to run simultaneously
  50. SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
  51. service_start /usr/sbin/sslh ${args}
  52. }
  53. start() {
  54. config_load 'sslh'
  55. config_foreach start_instance 'sslh'
  56. }
  57. stop() {
  58. service_stop /usr/sbin/sslh
  59. }