Update to namedrop 0.3.0

This commit is contained in:
Anders Pitman
2022-01-04 21:01:33 -07:00
parent f2d2e13e06
commit 7b4d8c40c0
3 changed files with 12 additions and 20 deletions

View File

@@ -179,12 +179,20 @@ func Listen() {
hostParts := strings.Split(r.Host, ":")
hostDomain := hostParts[0]
if r.URL.Path == "/namedrop/auth-success" {
if r.URL.Path == "/namedrop/callback" {
r.ParseForm()
errorParam := r.Form.Get("error")
requestId := r.Form.Get("state")
code := r.Form.Get("code")
if errorParam != "" {
db.DeleteDNSRequest(requestId)
http.Redirect(w, r, "/alert?message=Domain request failed", 303)
return
}
namedropTokenData, err := namedropClient.GetToken(requestId, code)
if err != nil {
w.WriteHeader(500)
@@ -242,24 +250,6 @@ func Listen() {
http.Redirect(w, r, fmt.Sprintf("https://%s/edit-tunnel?domain=%s", adminDomain, fqdn), 303)
}
} else if r.URL.Path == "/namedrop/auth-failure" {
r.ParseForm()
requestId := r.Form.Get("state")
// 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)

2
go.mod
View File

@@ -10,6 +10,7 @@ require (
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
github.com/takingnames/namedrop-go v0.3.0
)
require (
@@ -18,7 +19,6 @@ require (
github.com/libdns/libdns v0.2.1 // indirect
github.com/mholt/acmez v1.0.1 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/takingnames/namedrop-go v0.2.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect

2
go.sum
View File

@@ -138,6 +138,8 @@ github.com/takingnames/namedrop-go v0.1.0 h1:IqyV4/dpJWOK/csa5uB1+I6M5UAVyI/MY9n
github.com/takingnames/namedrop-go v0.1.0/go.mod h1:E3nx6fxAMfestthd1O3VhbaPesLaiYSGkWXRD1nIc88=
github.com/takingnames/namedrop-go v0.2.0 h1:iHxnQuLvaGP408A9JhtIddPGEb1Ho5N+pQVstdwM1tM=
github.com/takingnames/namedrop-go v0.2.0/go.mod h1:E3nx6fxAMfestthd1O3VhbaPesLaiYSGkWXRD1nIc88=
github.com/takingnames/namedrop-go v0.3.0 h1:qblZaAFQzkxOJvqVbqH3Oqevfd8mSkgF4k9QwS/vkGM=
github.com/takingnames/namedrop-go v0.3.0/go.mod h1:E3nx6fxAMfestthd1O3VhbaPesLaiYSGkWXRD1nIc88=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=