mirror of
https://github.com/zhigang1992/cow.git
synced 2026-04-30 10:22:32 +08:00
Blocked error page form generation.
This commit is contained in:
14
error.go
14
error.go
@@ -4,7 +4,6 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
@@ -23,10 +22,13 @@ var errPageRawTmpl = `<!DOCTYPE html>
|
||||
</html>
|
||||
`
|
||||
|
||||
var blockedFormRawTmpl = `<p> </p>
|
||||
<form action="http://{{.ListenAddr}}/blocked/{{.RequestURI}}" method="get">
|
||||
<input type="submit" name="retry" value="Retry">
|
||||
<input type="submit" name="add" value="Add {{.Domain}} to blocked sites">
|
||||
// Use GET to simplify form processing. Strictly speaking, this has side
|
||||
// effects and should use POST.
|
||||
var blockedFormRawTmpl = `<p></p>
|
||||
<form action="http://{{.ListenAddr}}/blocked" method="get">
|
||||
<input type="hidden" name="uri" value={{.RequestURI}}>
|
||||
<b>Refresh to retry</b> or
|
||||
<input type="submit" name="add" value="Add {{.Domain}} to blocked sites">
|
||||
</form>
|
||||
`
|
||||
|
||||
@@ -112,7 +114,7 @@ func sendBlockedErrorPage(w *bufio.Writer, errCodeReason, errMsg, detailedMsg st
|
||||
Domain string
|
||||
}{
|
||||
config.listenAddr,
|
||||
url.QueryEscape(r.toURI()), // escape URI to put it in request url
|
||||
r.URL.toURI(), // escape URI to put it in request url
|
||||
requestDomain(r),
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
Reference in New Issue
Block a user