From 87147ac89fc08bc4a1fff2c63aef9e6ec5a36ae7 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 17 Apr 2019 12:03:51 +0300 Subject: [PATCH] + control: /install/*: test TCP port availability for DNS server --- control.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/control.go b/control.go index 08747e7c..47c8c885 100644 --- a/control.go +++ b/control.go @@ -1059,6 +1059,10 @@ func handleInstallCheckConfig(w http.ResponseWriter, r *http.Request) { respData.DNS.CanAutofix = canAutofix } + if err == nil { + err = checkPortAvailable(reqData.DNS.IP, reqData.DNS.Port) + } + if err != nil { respData.DNS.Status = fmt.Sprintf("%v", err) } @@ -1161,8 +1165,13 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) { 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) + httpError(w, http.StatusBadRequest, "%s", err) + return + } + + err = checkPortAvailable(newSettings.DNS.IP, newSettings.DNS.Port) + if err != nil { + httpError(w, http.StatusBadRequest, "%s", err) return }