|
@@ -67,6 +67,9 @@ var guiTweet string
|
|
|
var mainTweets string
|
|
|
var archiveTweets string
|
|
|
|
|
|
+var mainInterestsString []string
|
|
|
+var archiveInterestsString []string
|
|
|
+
|
|
|
//this translates to a simulated round length of ~2h
|
|
|
var speedUp float64 = 7200 / ((maxTimePerRound.Seconds()) * 3)
|
|
|
|
|
@@ -187,6 +190,7 @@ func Client(clientNumber int, f *os.File) {
|
|
|
pos := receiveVirtualAddress(sharedSecret[clientNumber], leaderConn)
|
|
|
|
|
|
tweet := getGuiTweet()
|
|
|
+ //tweet := getRealTweet(clientNumber)
|
|
|
if clientNumber == numClients-1 {
|
|
|
log.Println("Round", round)
|
|
|
log.Println("publisherAmount", publisherAmount)
|
|
@@ -300,17 +304,23 @@ func Client(clientNumber int, f *os.File) {
|
|
|
|
|
|
//creates and sends the pirQuerys for each server
|
|
|
func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
|
- //later this will be taken from gui, this is only for testing
|
|
|
- topicsOfInterest := make([]int, 1)
|
|
|
- topicsOfInterest[0] = 0 //mr.Intn(10)
|
|
|
- archiveInterests[0] = 0 //mr.Intn(10)
|
|
|
+
|
|
|
+ topicsOfInterest := interestsToInt(mainInterestsString, 0)
|
|
|
+
|
|
|
+ //topicsOfInterest := make([]int, neededSubscriptions)
|
|
|
+ if len(topicsOfInterest) == 0 {
|
|
|
+ topicsOfInterest = make([]int, neededSubscriptions)
|
|
|
+ topicsOfInterest[0] = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("tpcofinterest", topicsOfInterest)
|
|
|
|
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
|
if tmpNeededSubscriptions > len(topicList) {
|
|
|
tmpNeededSubscriptions = len(topicList)
|
|
|
}
|
|
|
-
|
|
|
tmptopicsOfInterest := make([]int, len(topicsOfInterest))
|
|
|
+
|
|
|
copy(tmptopicsOfInterest, topicsOfInterest)
|
|
|
|
|
|
tmpTopicList := make([]string, len(topicList))
|
|
@@ -320,7 +330,11 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
|
if tmpNeededSubscriptions > len(archiveTopicList) {
|
|
|
tmpNeededSubscriptions = len(archiveTopicList)
|
|
|
}
|
|
|
- tmptopicsOfInterest = archiveInterests //todo! take archiveInterests from gui
|
|
|
+ tmptopicsOfInterest = interestsToInt(archiveInterestsString, 1)
|
|
|
+ if len(tmptopicsOfInterest) == 0 {
|
|
|
+ tmptopicsOfInterest = make([]int, neededSubscriptions)
|
|
|
+ tmptopicsOfInterest[0] = 0
|
|
|
+ }
|
|
|
tmpTopicList = archiveTopicList
|
|
|
}
|
|
|
|
|
@@ -475,8 +489,6 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
|
|
|
index := strings.Index(string(tweets), ";;")
|
|
|
|
|
|
- fmt.Println("received", string(tweets))
|
|
|
-
|
|
|
if index != -1 {
|
|
|
|
|
|
textArr := strings.Split(string(tweets), ";;;")
|
|
@@ -491,6 +503,8 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
goodPadding++
|
|
|
}
|
|
|
|
|
|
+ fmt.Println("received", text[0])
|
|
|
+
|
|
|
if getArchive {
|
|
|
if !strings.Contains(archiveTweets, text[0]) {
|
|
|
archiveTweets += text[0] + ";"
|
|
@@ -528,14 +542,67 @@ func GetTweets(whereFrom int) string {
|
|
|
|
|
|
for _, str := range tweetArr {
|
|
|
strArr := strings.Split(str, ";")
|
|
|
- tweets += "<li>" + strArr[0] + "<br>" + strArr[1] + "</li>"
|
|
|
+ tweets += "<li># " + strArr[0] + "<br>" + strArr[1] + "</li>"
|
|
|
}
|
|
|
|
|
|
- fmt.Println("tweetsToPost", tweets)
|
|
|
-
|
|
|
return tweets
|
|
|
}
|
|
|
|
|
|
+func GetTopicList(whereFrom int) string {
|
|
|
+
|
|
|
+ var tmpTopicList []string
|
|
|
+ var list string
|
|
|
+ label1 := `<label for="`
|
|
|
+ label2 := `">`
|
|
|
+ label3 := `</label>`
|
|
|
+
|
|
|
+ var box1 string
|
|
|
+ box2 := `" value="`
|
|
|
+ box3 := `" type="checkbox"/>`
|
|
|
+
|
|
|
+ if whereFrom == 0 {
|
|
|
+ tmpTopicList = topicList
|
|
|
+ box1 = `<input name="mainTopic" id="`
|
|
|
+ } else {
|
|
|
+ tmpTopicList = archiveTopicList
|
|
|
+ box1 = `<input name="archiveTopic" id="`
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, topic := range tmpTopicList {
|
|
|
+ list += label1 + topic + label2 + topic + label3 + box1 + topic + box2 + topic + box3 + "<br>"
|
|
|
+ }
|
|
|
+
|
|
|
+ return list
|
|
|
+}
|
|
|
+
|
|
|
+func interestsToInt(interests []string, whereFrom int) []int {
|
|
|
+ var interestsInt []int
|
|
|
+ var tmpTopicList []string
|
|
|
+ if whereFrom == 0 {
|
|
|
+ tmpTopicList = topicList
|
|
|
+ } else {
|
|
|
+ tmpTopicList = archiveTopicList
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, topic := range interests {
|
|
|
+ for index, str := range tmpTopicList {
|
|
|
+ if topic == str {
|
|
|
+ interestsInt = append(interestsInt, index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return interestsInt
|
|
|
+}
|
|
|
+
|
|
|
+func UpdateInterests(interests []string, whereTo int) {
|
|
|
+ if whereTo == 0 {
|
|
|
+ mainInterestsString = interests
|
|
|
+ } else {
|
|
|
+ archiveInterestsString = interests
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//creates a shared secret for each server
|
|
|
func createSharedSecret() [numClients][2][32]byte {
|
|
|
var tmpSharedSecret [numClients][2][32]byte
|