upd
This commit is contained in:
parent
476450b59e
commit
59ef6eff12
BIN
files/cursping.zip.tar.gz
Normal file
BIN
files/cursping.zip.tar.gz
Normal file
Binary file not shown.
36
main.go
36
main.go
@ -40,6 +40,10 @@ var trollingGifBase64 string
|
|||||||
var trollingHTML string
|
var trollingHTML string
|
||||||
var trollingHTMLOnce sync.Once
|
var trollingHTMLOnce sync.Once
|
||||||
|
|
||||||
|
var curpingFileBase64 string
|
||||||
|
var curpingFileName string
|
||||||
|
var curpingFileOnce sync.Once
|
||||||
|
|
||||||
func (rl *RateLimiter) canConnect(ip string) bool {
|
func (rl *RateLimiter) canConnect(ip string) bool {
|
||||||
rl.mutex.Lock()
|
rl.mutex.Lock()
|
||||||
defer rl.mutex.Unlock()
|
defer rl.mutex.Unlock()
|
||||||
@ -209,6 +213,9 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else if buffer == "icmp" {
|
} else if buffer == "icmp" {
|
||||||
conn.WriteJSON(map[string]string{"action": "show_message", "message": "\"Timestamp from icmp data...\" why is there a timestamp in the echo request?"})
|
conn.WriteJSON(map[string]string{"action": "show_message", "message": "\"Timestamp from icmp data...\" why is there a timestamp in the echo request?"})
|
||||||
buffer = ""
|
buffer = ""
|
||||||
|
} else if buffer == "cursping" {
|
||||||
|
conn.WriteJSON(map[string]string{"action": "redirect", "url": "/cursping.zip.tar.gz"})
|
||||||
|
buffer = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,6 +256,17 @@ func initTrollingHTML() {
|
|||||||
</html>`, trollingGifBase64)
|
</html>`, trollingGifBase64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initCurpingFile() {
|
||||||
|
fileContent, err := os.ReadFile("files/cursping.zip.tar.gz")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading curping file: %v", err)
|
||||||
|
fileContent = []byte("File not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
curpingFileBase64 = base64.StdEncoding.EncodeToString(fileContent)
|
||||||
|
curpingFileName = "curping"
|
||||||
|
}
|
||||||
|
|
||||||
func trollingHandler(w http.ResponseWriter, r *http.Request) {
|
func trollingHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
||||||
@ -258,6 +276,23 @@ func trollingHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
fmt.Fprint(w, trollingHTML)
|
fmt.Fprint(w, trollingHTML)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func curpingHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
curpingFileOnce.Do(initCurpingFile)
|
||||||
|
|
||||||
|
fileData, err := base64.StdEncoding.DecodeString(curpingFileBase64)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Error decoding file", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
|
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", curpingFileName))
|
||||||
|
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
||||||
|
w.Header().Set("Cache-Control", "public, max-age=3600")
|
||||||
|
|
||||||
|
w.Write(fileData)
|
||||||
|
}
|
||||||
|
|
||||||
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
||||||
@ -364,6 +399,7 @@ func main() {
|
|||||||
mux.HandleFunc("/ws", wsHandler)
|
mux.HandleFunc("/ws", wsHandler)
|
||||||
mux.HandleFunc("/status", gzipHandler(statusHandler))
|
mux.HandleFunc("/status", gzipHandler(statusHandler))
|
||||||
mux.HandleFunc("/trolling", gzipHandler(trollingHandler))
|
mux.HandleFunc("/trolling", gzipHandler(trollingHandler))
|
||||||
|
mux.HandleFunc("/cursping.zip.tar.gz", curpingHandler)
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: ":" + p,
|
Addr: ":" + p,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user