This commit is contained in:
Lain Iwakura 2025-07-13 01:10:45 +03:00
parent 476450b59e
commit 59ef6eff12
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8
2 changed files with 36 additions and 0 deletions

BIN
files/cursping.zip.tar.gz Normal file

Binary file not shown.

36
main.go
View File

@ -40,6 +40,10 @@ var trollingGifBase64 string
var trollingHTML string
var trollingHTMLOnce sync.Once
var curpingFileBase64 string
var curpingFileName string
var curpingFileOnce sync.Once
func (rl *RateLimiter) canConnect(ip string) bool {
rl.mutex.Lock()
defer rl.mutex.Unlock()
@ -209,6 +213,9 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
} 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?"})
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)
}
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) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
@ -258,6 +276,23 @@ func trollingHandler(w http.ResponseWriter, r *http.Request) {
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) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
@ -364,6 +399,7 @@ func main() {
mux.HandleFunc("/ws", wsHandler)
mux.HandleFunc("/status", gzipHandler(statusHandler))
mux.HandleFunc("/trolling", gzipHandler(trollingHandler))
mux.HandleFunc("/cursping.zip.tar.gz", curpingHandler)
server := &http.Server{
Addr: ":" + p,