-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpisec-proxy.go
More file actions
40 lines (30 loc) · 966 Bytes
/
pisec-proxy.go
File metadata and controls
40 lines (30 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"log"
"net/http"
"os"
"github.com/Ringloop/pisec/cache"
"github.com/Ringloop/pisec/handler"
"github.com/elazarl/goproxy"
)
var brainAddress string = os.Getenv("PISEC_BRAIN_ADDR")
var detailsEndpoint string = "/api/v1/indicators/details"
var indicatorsEndpoint string = "/api/v1/indicators"
var repo *cache.RedisRepository
var urlHandler *handler.PisecHandler
func main() {
//setup the REDIS cache
repo = cache.NewRedisClient()
server := &handler.Server{
BaseAddress: brainAddress,
IndicatorsEndpoint: indicatorsEndpoint,
DetailsEndpoint: detailsEndpoint,
}
//setup the filter
urlHandler = handler.NewUrlHandler(repo, server)
proxy := goproxy.NewProxyHttpServer()
proxy.OnRequest(urlHandler.IsMalwareRequestHttp()).DoFunc(handler.GetPiSecPage)
proxy.OnRequest(urlHandler.IsMalwareRequestHttps()).HandleConnect(goproxy.AlwaysReject)
proxy.Verbose = true
log.Fatal(http.ListenAndServe(":8880", proxy))
}