alloc.go 1006 B

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