Skip to content

Commit

Permalink
Add support for UXG series of Unifi product (#899)
Browse files Browse the repository at this point in the history
Fixes #889
  • Loading branch information
rs committed Jan 22, 2024
1 parent b71252c commit eebde6b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
13 changes: 12 additions & 1 deletion host/service/ubios/service.go
Expand Up @@ -12,6 +12,7 @@ package ubios
import (
"bufio"
"os"
"os/exec"
"strings"

"github.com/nextdns/nextdns/host/service"
Expand All @@ -23,8 +24,18 @@ type Service struct {
systemd.Service
}

func isUnifi() bool {
if st, _ := os.Stat("/data/unifi"); st != nil && st.IsDir() {
return true
}
if err := exec.Command("ubnt-device-info", "firmware").Run(); err == nil {
return true
}
return false
}

func New(c service.Config) (Service, error) {
if st, _ := os.Stat("/data/unifi"); st == nil || !st.IsDir() {
if !isUnifi() {
return Service{}, service.ErrNotSupported
}
srv := Service{
Expand Down
12 changes: 6 additions & 6 deletions install.sh
Expand Up @@ -101,13 +101,13 @@ uninstall() {
precheck() {
if [ -e "/data/unifi" ] && [ -f "/run/dnsfilter/dnsfilter" ]; then
log_warn "UDM Content Filtering and/or Ad Blocking feature is enabled."
log_warn "Please disable it to use NextDNS."
log_warn "Please disable it to use NextDNS."
log_warn ""
log_warn " To disable Content Filtering, go to Settings > Network."
log_warn " For each network, set the Content Filtering feature to None."
log_warn ""
log_warn " To disable Ad Blocking, go to Settings > Application Firewall"
log_warn " In the General tab, uncheck the Ad Blocking checkbox."
log_warn ""
log_warn " To disable Ad Blocking, go to Settings > Application Firewall"
log_warn " In the General tab, uncheck the Ad Blocking checkbox."
log_warn ""
while [ -f "/run/dnsfilter/dnsfilter" ]; do
sleep 1
Expand Down Expand Up @@ -1038,9 +1038,9 @@ bin_location() {
;;
synology)
echo "/usr/local/bin/nextdns"
;;
;;
darwin)
echo "$(brew --prefix 2>/dev/null || echo /usr/local)/bin/nextdns"
echo "$(brew --prefix 2>/dev/null || echo /usr/local)/bin/nextdns"
;;
asuswrt-merlin|ddwrt)
echo "/jffs/nextdns/nextdns"
Expand Down
12 changes: 11 additions & 1 deletion router/ubios/setup.go
Expand Up @@ -17,8 +17,18 @@ type Router struct {
ClientReporting bool
}

func isUnifi() bool {
if st, _ := os.Stat("/data/unifi"); st != nil && st.IsDir() {
return true
}
if err := exec.Command("ubnt-device-info", "firmware").Run(); err == nil {
return true
}
return false
}

func New() (*Router, bool) {
if st, _ := os.Stat("/data/unifi"); st == nil || !st.IsDir() {
if !isUnifi() {
return nil, false
}
return &Router{
Expand Down

0 comments on commit eebde6b

Please sign in to comment.