-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·40 lines (36 loc) · 1.06 KB
/
main.go
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 (
"flag"
"log"
"net/http"
"github.com/fidraC/canary/api/canaries"
"github.com/fidraC/canary/api/fingerprinting"
"github.com/fidraC/canary/crypto/tls"
"github.com/fidraC/canary/static"
)
func main() {
certPath := flag.String("cert", "", "Path to TLS certificate")
privKeyPath := flag.String("key", "", "Path to TLS private key")
flag.Parse()
var fingerprinter *fingerprinting.TLSHandler
if *certPath == "" || *privKeyPath == "" {
fingerprinter = fingerprinting.NewHandler(nil)
} else {
cert, err := tls.LoadX509KeyPair(*certPath, *privKeyPath)
if err != nil {
panic(err)
}
fingerprinter = fingerprinting.NewHandler(&cert)
}
listener, err := fingerprinting.NewListener(fingerprinter)
if err != nil {
panic(err)
}
router := http.NewServeMux()
router.HandleFunc("/finger", fingerprinter.ServeHTTP)
router.HandleFunc("/", static.StaticHandler)
router.HandleFunc("/configure", canaries.ConfigureHandler)
router.HandleFunc("/canaries", canaries.HandleGetCanaries)
log.Println("Listening on :443")
http.Serve(listener, router)
}