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.
 
 

53 lines
1.1 KiB

package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strconv"
)
func main() {
vip := os.Getenv("REVERSEURL")
pport := os.Getenv("PROXYPORT")
sensitivity := os.Getenv("TRIGGER")
maturity := os.Getenv("SENIORITY")
collect := os.Getenv("COLLECTION")
log.Println("Reverse path is: ", vip)
log.Println("Reverse port is: ", pport)
remote, err := url.Parse(vip)
if err != nil {
panic(err)
}
ProxyFlow.sensitivity, err = strconv.ParseFloat(sensitivity, 64)
if err != nil {
ProxyFlow.sensitivity = 0.5
}
log.Println("Trigger is: ", ProxyFlow.sensitivity)
Maturity, err = strconv.ParseInt(maturity, 10, 64)
if err != nil {
Maturity = 1024
}
log.Println("Minimum request to learn: ", Maturity)
ProxyFlow.collection, err = strconv.ParseFloat(collect, 64)
if err != nil {
// This is because we assume every example should add at least one token
ProxyFlow.collection = float64(Maturity)
}
log.Println("Collection limit is: ", ProxyFlow.collection)
proxy := httputil.NewSingleHostReverseProxy(remote)
http.HandleFunc("/", handler(proxy))
err = http.ListenAndServe(pport, nil)
if err != nil {
panic(err)
}
}