From a3140efb20e3c3ff00cc17cb45e00f8dc8f148d4 Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Tue, 21 Dec 2021 15:18:08 -0700 Subject: [PATCH] Implement domain request failure --- boringproxy.go | 18 ++++++++++++++++++ database.go | 7 ++++--- ui_handler.go | 7 +++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/boringproxy.go b/boringproxy.go index 9d15fc4..82f653a 100644 --- a/boringproxy.go +++ b/boringproxy.go @@ -288,6 +288,24 @@ func Listen() { http.Redirect(w, r, fmt.Sprintf("https://%s/edit-tunnel?domain=%s", adminDomain, domain), 303) } + } else if r.URL.Path == "/dnsapi/failure" { + + r.ParseForm() + + requestId := r.Form.Get("request-id") + + // Ensure the request exists + _, err := db.GetDNSRequest(requestId) + if err != nil { + w.WriteHeader(500) + io.WriteString(w, err.Error()) + return + } + + db.DeleteDNSRequest(requestId) + + http.Redirect(w, r, "/alert?message=Domain request failed", 303) + } else if hostDomain == db.GetAdminDomain() { if strings.HasPrefix(r.URL.Path, "/api/") { http.StripPrefix("/api", api).ServeHTTP(w, r) diff --git a/database.go b/database.go index 213c96b..34be1b2 100644 --- a/database.go +++ b/database.go @@ -35,9 +35,10 @@ type DNSRequest struct { } type DNSRecord struct { - Type string `json:"type"` - Value string `json:"value"` - TTL int `json:"ttl"` + Type string `json:"type"` + Value string `json:"value"` + TTL int `json:"ttl"` + Priority int `json:"priority"` } type Tunnel struct { diff --git a/ui_handler.go b/ui_handler.go index f6cc327..b3ef8d4 100644 --- a/ui_handler.go +++ b/ui_handler.go @@ -259,6 +259,13 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request http.Redirect(w, r, "/tunnels", 303) case "/loading": h.handleLoading(w, r) + case "/alert": + + r.ParseForm() + + message := r.Form.Get("message") + + h.alertDialog(w, r, message, "/") default: if strings.HasPrefix(r.URL.Path, "/tunnels/") {