Commit 8f4393c3 authored by owlo's avatar owlo

fighting!

parent 2bab6d69
No preview for this file type
......@@ -215,6 +215,23 @@ func runHackTrace(user string, target string, initializedActors []libs.ActorS) s
// return "NO"
return "OK"
}
func runBattleTrace(user string, target string, initializedActors []libs.ActorS) string {
userList := strings.Split(user, ":")
user = userList[0]
//index := 0
for i := range initializedActors {
if initializedActors[i].PreferredUsername == user {
// index = i
break
}
}
//if initializedActors[i].Stat > hitCalc()
// return "OK"
//else
// return "NO"
return "OK"
}
func upBork(borks []libs.ActorS) []byte {
borkFile, err := os.Create("tests/borks.json")
defer borkFile.Close()
......@@ -467,6 +484,36 @@ func main() {
w.Write(signedContent)
}
})
mux.HandleFunc("/getBattleTrace", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
// the trailers you will set during the HTTP
// response. These three headers are actually sent in
// the trailer.
fmt.Println("WHO FIGHTING?")
signed := req.Header.Get("Signature")
target := req.Header.Get("Target")
// signature := req.Header.Get("Authorization")
signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
if err != nil {
fmt.Println(err)
}
ok := validateLogin(signed, []byte(signature), initializedActors)
if ok {
w.Header().Set("Authorization", "ok")
w.WriteHeader(http.StatusOK)
//fmt.Println("GOT" + signed)
results := runBattleTrace(signed, target, initializedActors)
w.Header().Set("HackTrace", results)
w.Header().Set("Target", results)
w.Write([]byte(results))
} else {
w.Header().Set("Authorization", "not authorized")
w.Write([]byte("ennt!"))
}
})
mux.HandleFunc("/getHackTrace", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
// the trailers you will set during the HTTP
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment