alloc.go 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. //HTTPFlow is a type containg all the data we need.
  8. type HTTPFlow struct {
  9. request *http.Request
  10. response *http.Response
  11. sensitivity float64 // value who triggers decisions
  12. seniority int64
  13. }
  14. //DebugLog tells if logs are in debug mode or not
  15. var DebugLog bool
  16. //ProxyFlow represents our flow
  17. var ProxyFlow HTTPFlow
  18. //Classifier is our bayesian classifier
  19. var Classifier *ByClassifier
  20. //BlockMessage is the messgae we return when blocking
  21. var BlockMessage string
  22. //Maturity is the minimal amount of request , needed to say Zardoz has learnt enough
  23. var Maturity int64
  24. func init() {
  25. Classifier = new(ByClassifier)
  26. Classifier.enroll()
  27. ProxyFlow.sensitivity = 0.5
  28. ProxyFlow.seniority = 0
  29. bl, err := Asset("assets/message.txt")
  30. if err != nil {
  31. log.Println("Cannot marshal asset error message!!")
  32. BlockMessage = ""
  33. } else {
  34. BlockMessage = fmt.Sprintf("%s", bl)
  35. }
  36. }