alloc.go 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. refreshtime time.Duration
  15. }
  16. //DebugLog tells if logs are in debug mode or not
  17. var DebugLog bool
  18. //ProxyFlow represents our flow
  19. var ProxyFlow HTTPFlow
  20. //Classifier is our bayesian classifier
  21. var Classifier *ByClassifier
  22. //BlockMessage is the messgae we return when blocking
  23. var BlockMessage string
  24. //Maturity is the minimal amount of request , needed to say Zardoz has learnt enough
  25. var Maturity int64
  26. func init() {
  27. Classifier = new(ByClassifier)
  28. Classifier.enroll()
  29. ProxyFlow.sensitivity = 0.5
  30. ProxyFlow.seniority = 0
  31. bl, err := Asset("assets/message.txt")
  32. if err != nil {
  33. log.Println("Cannot marshal asset error message!!")
  34. BlockMessage = ""
  35. } else {
  36. BlockMessage = fmt.Sprintf("%s", bl)
  37. }
  38. }