diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-20 17:36:49 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-20 17:36:49 +0200 |
commit | 2fd1c7efe81d843b8828916ff692364cca2cc1c1 (patch) | |
tree | 3e15095e7fb36926061eaa2da3fd5271e3ee00bb /server | |
parent | b9b3551d79ae14c89088c233e655017724d59a08 (diff) |
added basic structure
An STFE server instance that dials the Trillian gRPC back-end, and which
listens on six different HTTP endpoints but without any actual processing.
Diffstat (limited to 'server')
-rw-r--r-- | server/main.go | 52 | ||||
-rwxr-xr-x | server/server | bin | 0 -> 14361514 bytes |
2 files changed, 52 insertions, 0 deletions
diff --git a/server/main.go b/server/main.go new file mode 100644 index 0000000..53ac8e6 --- /dev/null +++ b/server/main.go @@ -0,0 +1,52 @@ +// Package main provides an STFE binary +package main + +import ( + "flag" + "time" + + "net/http" + + "github.com/golang/glog" + "github.com/google/trillian" + "github.com/system-transparency/stfe" + "google.golang.org/grpc" + + ctutil "github.com/google/certificate-transparency-go/trillian/util" +) + +var ( + httpEndpoint = flag.String("http_endpoint", "localhost:6965", "host:port specification of where stfe serves clients") + rpcBackend = flag.String("log_rpc_server", "localhost:6962", "host:port specification of where Trillian serves clients") + prefix = flag.String("prefix", "/st/v1", "a prefix that proceeds each endpoint path") + trillianID = flag.Int64("trillianID", 5991359069696313945, "log identifier in the Trillian database") + rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "deadline for backend RPC requests") +) + +func main() { + flag.Parse() + + glog.Info("Dialling Trillian gRPC log server") + dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(*rpcDeadline)} + conn, err := grpc.Dial(*rpcBackend, dialOpts...) + if err != nil { + glog.Fatal(err) + } + + glog.Info("Creating HTTP request multiplexer") + mux := http.NewServeMux() + http.Handle("/", mux) + + glog.Info("Creating STFE server instance") + stfe_server := stfe.NewInstance(*prefix, *trillianID, trillian.NewTrillianLogClient(conn), *rpcDeadline, new(ctutil.SystemTimeSource)) + stfe_server.AddEndpoints(mux) + + glog.Infof("Serving on %v%v", *httpEndpoint, *prefix) + srv := http.Server{Addr: *httpEndpoint} + err = srv.ListenAndServe() + if err != http.ErrServerClosed { + glog.Warningf("Server exited: %v", err) + } + + glog.Flush() +} diff --git a/server/server b/server/server Binary files differnew file mode 100755 index 0000000..466879e --- /dev/null +++ b/server/server |