Introducing whitelist and blacklist
This commit is contained in:
parent
f7dac31974
commit
54b3e752d0
4 changed files with 38 additions and 2 deletions
4
blacklist.txt
Normal file
4
blacklist.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
penis
|
||||
wallet
|
||||
|
||||
|
3
file.go
3
file.go
|
@ -144,3 +144,6 @@ func init() {
|
|||
go jsonEngine()
|
||||
log.Printf("FIle Engine Started")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
31
matrix.go
31
matrix.go
|
@ -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
2
whitelist.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
guns
|
||||
cors
|
Loading…
Reference in a new issue