...
 
Commits (7)
......@@ -42,7 +42,7 @@ func validateLogin(signature string, file []byte, actors []libs.ActorS) bool {
florpScanner := bufio.NewScanner(florpReader)
for florpScanner.Scan() {
fmt.Println(florpScanner.Text())
//fmt.Println(florpScanner.Text())
if florpScanner.Text() == signature {
florptext := strings.Split(florpScanner.Text(), ":")
for i := range actors {
......@@ -163,7 +163,7 @@ func validate(signature string, file []byte) bool {
if err != nil {
fmt.Println("\033[2;255;0;0mERROR\033[0m")
}
fmt.Println(UIDed.Id)
//fmt.Println(UIDed.Id)
UIDWriter, err := os.Create("tests/" + string(UIDed.Id))
UIDWriter.Write(UIDData)
......@@ -222,7 +222,7 @@ func upBork(borks []libs.ActorS) []byte {
fmt.Println("error marshalling borks")
fmt.Println(err)
}
fmt.Println(borkJson)
//fmt.Println(borkJson)
borkFile.Write(borkJson)
return borkJson
......@@ -258,7 +258,7 @@ func updateBork(currentActors string) libs.ActorS {
}
//fmt.Println(k)
//fmt.Println(string(actorReader))
fmt.Println(mockup)
//fmt.Println(mockup)
return mockup
}
......@@ -294,7 +294,7 @@ func initActors(currentActors string) libs.ActorS {
}
//fmt.Println(k)
//fmt.Println(string(actorReader))
fmt.Println(mockup)
//fmt.Println(mockup)
emptyString := mockup
return emptyString
}
......@@ -364,7 +364,7 @@ func UIDMaker(typeS string) string {
thedog := rand.Intn(len(nouns))
uniqueFied := fmt.Sprint(uniquefier, hostname, username, adjectives[ind], adjectives[indie], nouns[thedog])
fmt.Println(uniqueFied)
//fmt.Println(uniqueFied)
if typeS == "post" {
numPosts, err := ioutil.ReadDir("tests/posts/")
......@@ -391,6 +391,7 @@ func main() {
if err != nil {
fmt.Println("No borks!")
}
fmt.Println("DIRBORKS:", dirBorks)
//room init
xvar := 17
yvar := 17
......@@ -398,8 +399,8 @@ func main() {
room = flour.Oven(room, "X", xvar, yvar)
room[122].Label = "player"
//end room init
numBorks := len(dirBorks)
numStringBorks := strconv.Itoa(numBorks)
//numBorks := len(dirBorks)
//numStringBorks := strconv.Itoa(numBorks)
fmt.Println("\033[38;2;20;20;255mInitializing actor accounts\033[0m")
currentActors, err := ioutil.ReadDir("tests/users/")
if err != nil {
......@@ -410,9 +411,9 @@ func main() {
initializedActors = append(initializedActors, initActors("tests/users/"+currentActors[i].Name()))
}
fmt.Println(initializedActors)
//fmt.Println(initializedActors)
fmt.Println("\033[48;2;255;20;20mInitialization Complete\033[0m")
fmt.Println(numStringBorks)
//fmt.Println(numStringBorks)
// fmt.Println("\033[38;2;0;255;0mThe most recent post is " + numBorks + "\033[0m")
for {
mux := http.NewServeMux()
......@@ -431,7 +432,7 @@ func main() {
if err != nil {
fmt.Println("Error reading post.")
}
fmt.Println(string(signedContent))
//fmt.Println(string(signedContent))
fmt.Println("Signing complete.")
w.Write(signedContent)
}
......@@ -503,7 +504,7 @@ func main() {
if err != nil {
fmt.Println("Error reading file")
}
fmt.Println(string(signedContent))
//fmt.Println(string(signedContent))
fmt.Println("Signing complete.")
w.Write(signedContent)
}
......@@ -524,7 +525,7 @@ func main() {
if err != nil {
fmt.Println("Error reading file")
}
fmt.Println(string(signedContent))
//fmt.Println(string(signedContent))
fmt.Println("Signing complete.")
w.Write(signedContent)
}
......@@ -539,7 +540,7 @@ func main() {
target := req.Header.Get("Target")
// signature := req.Header.Get("Authorization")
//signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
//fmt.Println(string(signed))
if err != nil {
fmt.Println(err)
}
......@@ -569,7 +570,7 @@ func main() {
target := req.Header.Get("Target")
// signature := req.Header.Get("Authorization")
// signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
//fmt.Println(string(signed))
if err != nil {
fmt.Println(err)
}
......@@ -592,10 +593,10 @@ func main() {
// response. These three headers are actually sent in
// the trailer.
fmt.Println("WHER GOING?")
signed := req.Header.Get("Signature")
//signed := req.Header.Get("Signature")
// signature := req.Header.Get("Authorization")
// signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
//fmt.Println(string(signed))
// if err != nil {
// fmt.Println(err)
// }
......@@ -746,10 +747,10 @@ func main() {
// response. These three headers are actually sent in
// the trailer.
fmt.Println("I HEAR BORK")
signed := req.Header.Get("Signature")
//signed := req.Header.Get("Signature")
// //signature := req.Header.Get("Authorization")
// signature, err := ioutil.ReadAll(req.Body)
fmt.Println(string(signed))
//fmt.Println(string(signed))
// if err != nil {
// fmt.Println(err)
// }
......@@ -792,12 +793,61 @@ func main() {
if err != nil {
fmt.Println("Error reading file")
}
fmt.Println(string(signedContent))
//fmt.Println(string(signedContent))
fmt.Println("Signing complete.")
w.Write(signedContent)
}
})
mux.HandleFunc("/post", 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.
//w.Header().Set("NumBorks", numPosts)
w.WriteHeader(http.StatusOK)
fmt.Println("Signing test json.")
if req.Header.Get("Accept") == "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" {
fmt.Println("Accept header is correct.")
w.Header().Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
//w.Header().Set("Authentication", //signature)
signedContent, err := ioutil.ReadAll(req.Body)
if err != nil {
panic(err)
} else {
output := fmt.Sprint("======================", signedContent, "========================")
fmt.Println(output)
}
//TODO
name := UIDMaker("post")
file, err := os.Create("tests/"+name)
defer file.Close()
numBytes, err := file.WriteString(string(signedContent))
if err != nil {
fmt.Println(name)
fmt.Println("ERROR CREATING FILE")
panic(err)
}else {
fmt.Println("Wrote ", numBytes, " bytes")
file.Sync()
}
var borks []libs.ActorS
posts, err := ioutil.ReadDir("tests/posts/")
if err != nil {
fmt.Println(err)
}
for _, v := range posts {
borks = append(borks, updateBork("tests/posts/"+v.Name()))
}
//numPosts := strconv.Itoa(len(posts))
upBork(borks)
w.Write(signedContent)
}
})
//CREATE USER
......@@ -810,53 +860,6 @@ func main() {
// the trailer.
// fmt.Println("SOMEONE IS PREPARING TO BORK.")
//defer resp.Body.Close()
//THIS NEEDS TO BE AVAILABLE AS A RESPONSE TO THAT^^
//{
// "subject": "acct:alice@my-example.com",
//
// "links": [
// {
// "rel": "self",
// "type": "application/activity+json",
// "href": "https://my-example.com/actor"
// }
// ]
//}
// object, err := ioutil.ReadAll(req.Body)
// req.Body.Close()
// if err != nil {
// fmt.Println("Error reading reponse.")
// fmt.Println(err)
// }
// beachBall := object
// fmt.Println(beachBall)
// UID := UIDMaker("post")
// validate(UID, object)
//ALSO THE KEY HAS TO BE AVAILBLE TO WEBFINGER LIKE SO
// {
// "@context": "https://www.w3.org/ns/activitystreams",
//
// "id": "https://my-example.com/create-hello-world",
// "type": "Create",
// "actor": "https://my-example.com/actor",
//
// "object": {
// "id": "https://my-example.com/hello-world",
// "type": "Note",
// "published": "2018-06-23T17:17:11Z",
// "attributedTo": "https://my-example.com/actor",
// "inReplyTo": "https://mastodon.social/@Gargron/100254678717223630",
// "content": "<p>Hello world</p>",
// "to": "https://www.w3.org/ns/activitystreams#Public"
// }
// }
// })
// http.ListenAndServe(":443", mux)
// }
mux.HandleFunc("/exampleposter", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
// the trailers you will set during the HTTP
......@@ -872,8 +875,8 @@ func main() {
fmt.Println("Error reading reponse.")
fmt.Println(err)
}
beachBall := object
fmt.Println(beachBall)
//beachBall := object
//fmt.Println(beachBall)
UID := UIDMaker("post")
validate(UID, object)
......