@@ -29,9 +29,7 @@ import (
29
29
"time"
30
30
31
31
"github.com/google/trillian/monitoring/opencensus"
32
- "github.com/google/trillian/monitoring/prometheus"
33
32
"github.com/prometheus/client_golang/prometheus/promhttp"
34
- "github.com/rs/cors"
35
33
sctfe "github.com/transparency-dev/static-ct"
36
34
gcpSCTFE "github.com/transparency-dev/static-ct/storage/gcp"
37
35
tessera "github.com/transparency-dev/trillian-tessera"
@@ -76,7 +74,6 @@ func main() {
76
74
flag .Parse ()
77
75
ctx := context .Background ()
78
76
79
- timeSource := sctfe.SystemTimeSource {}
80
77
signer , err := NewSecretManagerSigner (ctx , * signerPublicKeySecretName , * signerPrivateKeySecretName )
81
78
if err != nil {
82
79
klog .Exitf ("Can't create secret manager signer: %v" , err )
@@ -92,58 +89,20 @@ func main() {
92
89
NotAfterLimit : notAfterLimit .t ,
93
90
}
94
91
95
- log , err := sctfe .NewLog (ctx , * origin , signer , chainValidationConfig , timeSource , newGCPStorage )
92
+ logHandler , err := sctfe .NewLogHandler (ctx , * origin , signer , chainValidationConfig , newGCPStorage , * httpDeadline , * maskInternalErrors )
96
93
if err != nil {
97
- klog .Exitf ("Invalid log config : %v" , err )
94
+ klog .Exitf ("Can't initialize CT HTTP Server : %v" , err )
98
95
}
99
96
100
- opts := & sctfe.HandlerOptions {
101
- Deadline : * httpDeadline ,
102
- MetricFactory : prometheus.MetricFactory {},
103
- RequestLog : & sctfe.DefaultRequestLog {},
104
- MaskInternalErrors : * maskInternalErrors ,
105
- TimeSource : timeSource ,
106
- }
107
-
108
- handlers := sctfe .NewPathHandlers (opts , log )
109
-
110
97
klog .CopyStandardLogTo ("WARNING" )
111
98
klog .Info ("**** CT HTTP Server Starting ****" )
99
+ http .Handle ("/" , logHandler )
112
100
113
101
metricsAt := * metricsEndpoint
114
102
if metricsAt == "" {
115
103
metricsAt = * httpEndpoint
116
104
}
117
105
118
- // Allow cross-origin requests to all handlers registered on corsMux.
119
- // This is safe for CT log handlers because the log is public and
120
- // unauthenticated so cross-site scripting attacks are not a concern.
121
- corsMux := http .NewServeMux ()
122
- corsHandler := cors .AllowAll ().Handler (corsMux )
123
- http .Handle ("/" , corsHandler )
124
-
125
- // Register handlers for all the configured logs.
126
- for path , handler := range handlers {
127
- corsMux .Handle (path , handler )
128
- }
129
-
130
- // Return a 200 on the root, for GCE default health checking :/
131
- corsMux .HandleFunc ("/" , func (resp http.ResponseWriter , req * http.Request ) {
132
- if req .URL .Path == "/" {
133
- resp .WriteHeader (http .StatusOK )
134
- } else {
135
- resp .WriteHeader (http .StatusNotFound )
136
- }
137
- })
138
-
139
- // Export a healthz target.
140
- corsMux .HandleFunc ("/healthz" , func (resp http.ResponseWriter , req * http.Request ) {
141
- // TODO(al): Wire this up to tell the truth.
142
- if _ , err := resp .Write ([]byte ("ok" )); err != nil {
143
- klog .Errorf ("resp.Write(): %v" , err )
144
- }
145
- })
146
-
147
106
if metricsAt != * httpEndpoint {
148
107
// Run a separate handler for metrics.
149
108
go func () {
0 commit comments