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.

48 lines
1.0 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=80
  3. USE_PROCD=1
  4. PROG=/usr/sbin/https_dns_proxy
  5. start_instance() {
  6. local cfg="$1"
  7. local listen_addr listen_port user group
  8. config_get listen_addr "$cfg" listen_addr
  9. config_get listen_port "$cfg" listen_port
  10. config_get user "$cfg" user
  11. config_get group "$cfg" group
  12. config_get subnet_addr "$cfg" subnet_addr
  13. config_get proxy_server "$cfg" proxy_server
  14. config_get url_prefix "$cfg" url_prefix
  15. if [ -n "$subnet_addr" ]; then
  16. subnet_param="-e $subnet_addr"
  17. fi
  18. if [ -n "$proxy_server" ]; then
  19. proxy_param="-t $proxy_server"
  20. fi
  21. if [ -z "$url_prefix" ]; then
  22. url_prefix="https://dns.google.com/resolve?"
  23. fi
  24. procd_open_instance
  25. procd_set_param command ${PROG} \
  26. -a "$listen_addr" -p "$listen_port" \
  27. -u "$user" -g "$group" $subnet_param $proxy_param \
  28. -r "$url_prefix"
  29. procd_set_param respawn
  30. procd_close_instance
  31. }
  32. service_triggers() {
  33. procd_add_reload_trigger "https_dns_proxy"
  34. }
  35. start_service() {
  36. config_load 'https_dns_proxy'
  37. config_foreach start_instance 'https_dns_proxy'
  38. }