first commit
This commit is contained in:
commit
8915771c4e
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module github.com/cryptexctl/gbio
|
||||
|
||||
go 1.24.4
|
||||
|
||||
require github.com/gorilla/websocket v1.5.3 // indirect
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
153
main.go
Normal file
153
main.go
Normal file
@ -0,0 +1,153 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
||||
type KeyPress struct {
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
func wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
log.Printf("WebSocket upgrade error: %v", err)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
var buffer string
|
||||
var lastPress time.Time
|
||||
|
||||
for {
|
||||
var keyPress KeyPress
|
||||
err := conn.ReadJSON(&keyPress)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
if now.Sub(lastPress) > 5*time.Second {
|
||||
buffer = ""
|
||||
}
|
||||
lastPress = now
|
||||
|
||||
buffer += keyPress.Key
|
||||
|
||||
if len(buffer) > 20 {
|
||||
buffer = buffer[len(buffer)-20:]
|
||||
}
|
||||
|
||||
if buffer == "lain" {
|
||||
conn.WriteJSON(map[string]string{"action": "redirect", "url": "https://fauux.neocities.org"})
|
||||
buffer = ""
|
||||
} else if buffer == "rabbit" {
|
||||
conn.WriteJSON(map[string]string{"action": "show_message", "message": "wake up, Neo"})
|
||||
buffer = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
query := r.URL.Query().Get("q")
|
||||
|
||||
if query == "lain" {
|
||||
http.Redirect(w, r, "https://fauux.neocities.org", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
html := `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>0BSD_FOR_EVERYONE</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Courier New', monospace;
|
||||
background-color: #000;
|
||||
color: #00ff00;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
font-size: 3em;
|
||||
text-shadow: 0 0 10px #00ff00;
|
||||
position: relative;
|
||||
}
|
||||
#y{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);color:#ff0000;font-size:1.5em;text-shadow:0 0 10px #ff0000;display:none;z-index:1000}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
0BSD_FOR_EVERYONE
|
||||
<div id="y">wake up, Neo</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
var ws=new WebSocket('ws://'+window.location.host+'/ws');
|
||||
var buffer='';
|
||||
var lastPress=Date.now();
|
||||
|
||||
ws.onopen=function(){};
|
||||
ws.onmessage=function(e){
|
||||
var data=JSON.parse(e.data);
|
||||
if(data.action==='redirect')window.location.href=data.url;
|
||||
if(data.action==='show_message'){
|
||||
var msg=document.getElementById('y');
|
||||
msg.style.display='block';
|
||||
setTimeout(function(){msg.style.display='none'},3000);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('keydown',function(e){
|
||||
var now=Date.now();
|
||||
if(now-lastPress>5000)buffer='';
|
||||
lastPress=now;
|
||||
|
||||
buffer+=e.key.toLowerCase();
|
||||
if(buffer.length>20)buffer=buffer.slice(-20);
|
||||
|
||||
ws.send(JSON.stringify({key:e.key.toLowerCase()}));
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>`
|
||||
fmt.Fprint(w, html)
|
||||
}
|
||||
|
||||
func main() {
|
||||
ports := []string{"1337", "1488", "13373", "33737", "25575", "80", "8080"}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for _, port := range ports {
|
||||
wg.Add(1)
|
||||
go func(p string) {
|
||||
defer wg.Done()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", handler)
|
||||
mux.HandleFunc("/ws", wsHandler)
|
||||
log.Printf("Сервер запущен на порту %s", p)
|
||||
if err := http.ListenAndServe(":"+p, mux); err != nil {
|
||||
log.Printf("Ошибка на порту %s: %v", p, err)
|
||||
}
|
||||
}(port)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user