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.

71 lines
2.1 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) tls parameter
  21. config_get val "${section}" tls
  22. [ -n "${val}" ] && append args "--tls ${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. # K) transparent parameter
  46. config_get_bool val "${section}" transparent 0
  47. [ "${val}" -ne 0 ] && append args "--transparent"
  48. # Defaults were removed for --user and --pidfile options
  49. # in sslh 1.11; Define them here instead.
  50. append args "--user nobody"
  51. append args "--pidfile /var/run/sslh.pid"
  52. # XXX: allow more that one instance to run simultaneously
  53. SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
  54. service_start /usr/sbin/sslh ${args}
  55. }
  56. start() {
  57. config_load 'sslh'
  58. config_foreach start_instance 'sslh'
  59. }
  60. stop() {
  61. service_stop /usr/sbin/sslh
  62. }