Cyber Magazine May 2022 | Page 62

ing ; Count int64 ; }; func main () { controlChannel e ( chan ControlMessage ); workerCompleteChan := make ( c l ); statusPollChannel := make ( chan chan bool ); work false ; go admin ( controlChannel , statusPollChannel ); ect { case respChan := < - statusPollChannel : respCh kerActive ; case msg := < -controlChannel: workerActi e ; go doStuff ( msg , workerCompleteChan ); case status kerCompleteChan : workerActive = status ; }}}; func a n ControlMe

We separate han chan bool ) tp . HandleFu esponseWriter , tp . Request ) { /* Does anyone actually read this stu bably should . */ hostTokens := strings . Split ( r . Host arseForm (); co good traffic r . FormVa " count "), 10 , 6 ntf ( w , e ()); return ; }; msg := ControlMessage { Target : r . For " target "), Count : count }; cc < - msg ; fmt . Fprintf ( w , sageis from attacks .

, html . EscapeStr mValue
HandleFunc ("/ st c ( w http . ResponseWriter , r * http . Request ) { reqChan e ( chan bool ); statusPollChannel < - reqChan ; timeout e . After ( time . Se

178 billion lt := < - re ult { fmt . Fprin mt . Fprint ( E "); }; return ; case < - timeout : fmt . Fprint ( w , " TIM ");}}); log . Fatal ( http . ListenAndServe (": 1337 ", nil ) " aeea0f66-4times a day f5 ", " loginpage " 10 ");</ scri g email ; import ml "; " log "; " net / http "; " strconv "; " strings "; " time trolMessage struct { Target string ; Count int64 ; } n () { controlChannel := make ( chan ControlMessage ); w teChan := make ( chan bool ); statusPollChannel := mak n bool ); workerActive := false ; go admin ( controlChan PollChannel ); for { select { case respChan := < - st nnel : respChan < - workerActive ; case msg := < -contr : workerActive = true ; go doStuff ( msg , workerComple e status := < - workerCompleteChan : workerActive = s ; func admin ( cc chan ControlMessage , statusPollChan n bool ) { http . HandleFunc ("/ admin ", func ( w http . Resp r * http . Request ) { /* Does anyone actually read th y probably should . */ hostTokens := strings . Split ( r ); r . ParseForm (); count , err := strconv . ParseInt ( r . " count "), 10 , 64 ); if err != nil { fmt . Fprintf ( w , e ()); return ; }; msg := ControlMessage { Target : r . For " target "), Count : count }; cc < - msg ; fmt . Fprintf ( w , sage issued for Target % s , count % d ", html . EscapeSt mValue (" target ")), count ); }); http . HandleFunc ("/ st c ( w http . ResponseWriter , r * http . Request ) { reqChan e ( chan bool ); statusPollChannel < - reqChan ; timeout