Zardoz is a small WFA which tries to learn from the server and client the rules of what to block.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1006 B

package main
import (
"fmt"
"log"
"net/http"
"time"
)
//HTTPFlow is a type containg all the data we need.
type HTTPFlow struct {
request *http.Request
response *http.Response
sensitivity float64 // value who triggers decisions
seniority int64
collection float64
refreshtime time.Duration
}
//DebugLog tells if logs are in debug mode or not
var DebugLog bool
//ProxyFlow represents our flow
var ProxyFlow HTTPFlow
//ZClassifier is our bayesian classifier
var ZClassifier *ByClassifier
//BlockMessage is the messgae we return when blocking
var BlockMessage string
//Maturity is the minimal amount of request , needed to say Zardoz has learnt enough
var Maturity int64
func init() {
ZClassifier = new(ByClassifier)
ZClassifier.enroll()
ProxyFlow.sensitivity = 0.5
ProxyFlow.seniority = 0
bl, err := Asset("assets/message.txt")
if err != nil {
log.Println("Cannot marshal asset error message!!")
BlockMessage = ""
} else {
BlockMessage = fmt.Sprintf("%s", bl)
}
}