-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthd.go
45 lines (36 loc) · 833 Bytes
/
authd.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
41
42
43
44
45
package main
import (
"flag"
"log"
"net"
"github.com/cockroachdb/cmux"
"github.com/dhtech/authservice/audit"
"github.com/dhtech/authservice/rpc"
"github.com/dhtech/authservice/sign"
"github.com/dhtech/authservice/verify"
"github.com/dhtech/authservice/webui"
)
var (
listenAddress = flag.String("listen", ":1214", "Address to listen to")
)
func main() {
flag.Parse()
s, err := net.Listen("tcp", *listenAddress)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
mux := cmux.New(s)
sg := mux.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))
sh := mux.Match(cmux.Any())
a := audit.New()
si := sign.New(a)
w := webui.New()
v := verify.New(w, si)
r := rpc.New(v)
go r.Serve(sg)
go w.Serve(sh)
err = mux.Serve()
if err != nil {
log.Fatalf("failed to serve mux: %v", err)
}
}