Introducing whitelist and blacklist

This commit is contained in:
Loweel 2019-12-05 11:40:07 +01:00
parent f7dac31974
commit 54b3e752d0
4 changed files with 38 additions and 2 deletions

4
blacklist.txt Normal file
View file

@ -0,0 +1,4 @@
penis
wallet

View file

@ -144,3 +144,6 @@ func init() {
go jsonEngine()
log.Printf("FIle Engine Started")
}

View file

@ -1,6 +1,7 @@
package main
import (
"bufio"
"fmt"
"log"
"os"
@ -161,8 +162,8 @@ func (c *ByClassifier) enroll() {
ControPlane.GoodTokens = make(chan string, 2048)
ControPlane.StatsTokens = make(chan string, 2048)
c.IsBAD("/Penis/bad")
c.IsGOOD("/Gun/good")
c.readInitList("blacklist.txt", "BAD")
c.readInitList("whitelist.txt", "GOOD")
c.MEH.Store("Dildo", time.Now().UnixNano())
go c.readBadTokens()
@ -266,3 +267,29 @@ func (c *ByClassifier) CleanMEH() {
}
}
func (c *ByClassifier) readInitList(filePath, class string) {
inFile, err := os.Open(filePath)
if err != nil {
log.Println(err.Error() + `: ` + filePath)
return
}
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
for scanner.Scan() {
if len(scanner.Text()) > 3 {
switch class {
case "BAD":
log.Println("Loading into Blacklist: ", scanner.Text()) // the line
c.IsBAD(scanner.Text())
case "GOOD":
log.Println("Loading into Whitelist: ", scanner.Text()) // the line
c.IsGOOD(scanner.Text())
}
}
}
}

2
whitelist.txt Normal file
View file

@ -0,0 +1,2 @@
guns
cors