zardoz/alloc.go
2019-12-03 16:41:09 +01:00

50 lines
981 B
Go

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
refreshtime time.Duration
}
//DebugLog tells if logs are in debug mode or not
var DebugLog bool
//ProxyFlow represents our flow
var ProxyFlow HTTPFlow
//Classifier is our bayesian classifier
var Classifier *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() {
Classifier = new(ByClassifier)
Classifier.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)
}
}