Last active
April 22, 2023 00:43
-
-
Save kurochan/6269211231c534386a2bc1156500ebcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; import ( "fmt"; "html"; "lo | |
"net/http"; "strconv"; "strings"; "time" | |
trolMessage struct { Target string; Count | |
func main() { controlChannel := make(chan | |
sage);workerComplechan := make(chan boo | |
PollChannel := make(chan chan bool); work | |
false; go admin(controlChannel, statusPoll | |
{ select { case respChan := <- statusPoll | |
Chan <- workerActive; case msg := <- countr | |
workerActive = true; go doStuff(msg, work | |
teChan); case status := <- workerComplete | |
Active = status;}}}; func admin(cc chan | |
sage, statusPollChannel chan chan bool){ | |
Func("/admin", func(w http.ResponseWriter | |
quest) { hostTokens := strings.Split(r.Ho | |
r.ParseForm(); count, err := strconv.Pars | |
Value("count"), 10, 32); if err != nil { | |
err.Error()); return;}; msg := ControlMe | |
r.FormValue("target"), Count: count}; cc | |
printf(w, "Control message issued for Tar | |
%d", html.EscapeString(r.FormValue("targe | |
}); http.HandleFunc("/status", func(w http | |
er, r *http.Request) { reqChan := make(ch | |
tusPollChannel <- reqChan;timeout := time | |
time.Second); select { case result := <- | |
result { fmt.Fprint(w, "ACTIVE"); } else | |
print(w, "INACTIVE"); }; retu PEACE FOR ALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment