mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Improve TakingNames.io request generation
Before we were pre-generating a DNS request ID every time the add tunnel page was visited. Now we have a separate endpoint for generating the IDs only after the user indicates they actually want to perform a TakingNames.io domain request.
This commit is contained in:
parent
a3140efb20
commit
e83df3478f
@ -5,7 +5,7 @@
|
||||
<div class='input'>
|
||||
<p>
|
||||
Enter a domain below, or automatically configure DNS using
|
||||
<a href='{{$.TakingNamesLink}}'>TakingNames.io</a>
|
||||
<a href='/takingnames'>TakingNames.io</a>
|
||||
</p>
|
||||
<label for="domain">Domain:</label>
|
||||
<input type="text" id="domain" name="domain" value="{{$.Domain}}" required>
|
||||
|
@ -160,36 +160,16 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
|
||||
users[tokenData.Owner] = user
|
||||
}
|
||||
|
||||
requestId, _ := genRandomCode(32)
|
||||
|
||||
req := DNSRequest{
|
||||
Records: []*DNSRecord{
|
||||
&DNSRecord{
|
||||
Type: "A",
|
||||
Value: h.config.PublicIp,
|
||||
TTL: 300,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
h.db.SetDNSRequest(requestId, req)
|
||||
|
||||
adminDomain := h.db.GetAdminDomain()
|
||||
|
||||
tnLink := fmt.Sprintf("https://takingnames.io/dnsapi?requester=%s&request-id=%s", adminDomain, requestId)
|
||||
|
||||
templateData := struct {
|
||||
Domain string
|
||||
UserId string
|
||||
User User
|
||||
Users map[string]User
|
||||
TakingNamesLink string
|
||||
Domain string
|
||||
UserId string
|
||||
User User
|
||||
Users map[string]User
|
||||
}{
|
||||
Domain: domain,
|
||||
UserId: tokenData.Owner,
|
||||
User: user,
|
||||
Users: users,
|
||||
TakingNamesLink: tnLink,
|
||||
Domain: domain,
|
||||
UserId: tokenData.Owner,
|
||||
User: user,
|
||||
Users: users,
|
||||
}
|
||||
|
||||
err = h.tmpl.ExecuteTemplate(w, "edit_tunnel.tmpl", templateData)
|
||||
@ -266,6 +246,26 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
|
||||
message := r.Form.Get("message")
|
||||
|
||||
h.alertDialog(w, r, message, "/")
|
||||
case "/takingnames":
|
||||
requestId, _ := genRandomCode(32)
|
||||
|
||||
req := DNSRequest{
|
||||
Records: []*DNSRecord{
|
||||
&DNSRecord{
|
||||
Type: "A",
|
||||
Value: h.config.PublicIp,
|
||||
TTL: 300,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
h.db.SetDNSRequest(requestId, req)
|
||||
|
||||
adminDomain := h.db.GetAdminDomain()
|
||||
|
||||
tnLink := fmt.Sprintf("https://takingnames.io/dnsapi?requester=%s&request-id=%s", adminDomain, requestId)
|
||||
|
||||
http.Redirect(w, r, tnLink, 303)
|
||||
default:
|
||||
if strings.HasPrefix(r.URL.Path, "/tunnels/") {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user