diff --git a/app.go b/app.go index e72a7f2c..7c0b6b20 100644 --- a/app.go +++ b/app.go @@ -149,6 +149,7 @@ func run(args options) { // add handlers for /install paths, we only need them when we're not configured yet if config.firstRun { + log.Printf("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } diff --git a/client/package-lock.json b/client/package-lock.json index 17cf18c3..380bd20d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -9122,7 +9122,8 @@ "merge": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", - "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==" + "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", + "dev": true }, "merge-descriptors": { "version": "1.0.1", diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 3cdeddad..2bae1d12 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -160,7 +160,7 @@ "filter_label": "Filter", "unknown_filter": "Unknown filter {{filterId}}", "install_welcome_title": "Welcome to AdGuard Home!", - "install_welcome_desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit.", + "install_welcome_desc": "AdGuard Home is a network-wide ad-and-tracker blocking DNS server. Its purpose is to let you control your entire network and all your devices, and it does not require using a client-side program.", "install_settings_title": "Admin Web Interface", "install_settings_listen": "Listen interface", "install_settings_port": "Port", diff --git a/control.go b/control.go index 1691c370..52a9e221 100644 --- a/control.go +++ b/control.go @@ -723,7 +723,7 @@ func handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { // fill out the fields // find out if port 80 is available -- if not, fall back to 3000 - if checkPortAvailable("", 80) { + if checkPortAvailable("", 80) == nil { data.Web.Port = 80 } else { data.Web.Port = 3000 @@ -731,15 +731,15 @@ func handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { // find out if port 53 is available -- if not, show a big warning data.DNS.Port = 53 - if !checkPacketPortAvailable("", 53) { + if checkPacketPortAvailable("", 53) != nil { data.DNS.Warning = "Port 53 is not available for binding -- this will make DNS clients unable to contact AdGuard Home." } data.Interfaces = make(map[string]interface{}) for _, iface := range ifaces { for i := range iface.Addresses { - ip, _, err := net.ParseCIDR(iface.Addresses[i]) - if err != nil { + ip, _, e := net.ParseCIDR(iface.Addresses[i]) + if e != nil { continue } iface.Addresses[i] = ip.String() @@ -764,13 +764,15 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) { } // validate that hosts and ports are bindable - if !checkPortAvailable(newSettings.Web.IP, newSettings.Web.Port) { - httpError(w, http.StatusBadRequest, "Impossible to listen on IP:port %s", net.JoinHostPort(newSettings.Web.IP, strconv.Itoa(newSettings.Web.Port))) + err = checkPortAvailable(newSettings.Web.IP, newSettings.Web.Port) + if err != nil { + httpError(w, http.StatusBadRequest, "Impossible to listen on IP:port %s due to %s", net.JoinHostPort(newSettings.Web.IP, strconv.Itoa(newSettings.Web.Port)), err) return } - if !checkPacketPortAvailable(newSettings.DNS.IP, newSettings.DNS.Port) { - httpError(w, http.StatusBadRequest, "Impossible to listen on IP:port %s", net.JoinHostPort(newSettings.DNS.IP, strconv.Itoa(newSettings.DNS.Port))) + err = checkPacketPortAvailable(newSettings.DNS.IP, newSettings.DNS.Port) + if err != nil { + httpError(w, http.StatusBadRequest, "Impossible to listen on IP:port %s due to %s", net.JoinHostPort(newSettings.DNS.IP, strconv.Itoa(newSettings.DNS.Port)), err) return } diff --git a/helpers.go b/helpers.go index 9dbd59b7..0e4b1bf1 100644 --- a/helpers.go +++ b/helpers.go @@ -14,8 +14,6 @@ import ( "runtime" "strconv" "strings" - - "github.com/hmage/golibs/log" ) // ---------------------------------- @@ -124,7 +122,7 @@ func preInstall(handler func(http.ResponseWriter, *http.Request)) func(http.Resp } } -// preInstallStruct wraps preInstall into a struct that can be returned as an interface where neccessary +// preInstallStruct wraps preInstall into a struct that can be returned as an interface where necessary type preInstallHandlerStruct struct { handler http.Handler } @@ -241,41 +239,23 @@ func getValidNetInterfaces() ([]netInterface, error) { return netIfaces, nil } -func findIPv4IfaceAddr(ifaces []netInterface) string { - for _, iface := range ifaces { - for _, addr := range iface.Addresses { - ip, _, err := net.ParseCIDR(addr) - if err != nil { - log.Printf("SHOULD NOT HAPPEN: got iface.Addresses element that's not a parseable CIDR: %s", addr) - continue - } - if ip.To4() == nil { - log.Tracef("Ignoring IP that isn't IPv4: %s", ip) - continue - } - return ip.To4().String() - } - } - return "" -} - // checkPortAvailable is not a cheap test to see if the port is bindable, because it's actually doing the bind momentarily -func checkPortAvailable(host string, port int) bool { +func checkPortAvailable(host string, port int) error { ln, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port))) if err != nil { - return false + return err } ln.Close() - return true + return nil } -func checkPacketPortAvailable(host string, port int) bool { +func checkPacketPortAvailable(host string, port int) error { ln, err := net.ListenPacket("udp", net.JoinHostPort(host, strconv.Itoa(port))) if err != nil { - return false + return err } ln.Close() - return true + return err } // ---------------------