@@ -17,8 +17,44 @@ import (
1717 "net/http"
1818 "strings"
1919 "sync"
20+ "sync/atomic"
2021)
2122
23+ var (
24+ processedCerts int64
25+ processedPrecerts int64
26+ urlMapMutex sync.RWMutex
27+ urlMap = make (map [string ]int64 )
28+ )
29+
30+ func GetProcessedCerts () int64 {
31+ return processedCerts
32+ }
33+
34+ func GetProcessedPrecerts () int64 {
35+ return processedPrecerts
36+ }
37+
38+ func GetCertCountForLog (logname string ) int64 {
39+ urlMapMutex .RLock ()
40+ defer urlMapMutex .RUnlock ()
41+ return urlMap [logname ]
42+ }
43+
44+ func GetLogs () []string {
45+ urlMapMutex .RLock ()
46+ defer urlMapMutex .RUnlock ()
47+
48+ urls := make ([]string , len (urlMap ))
49+
50+ counter := 0
51+ for key := range urlMap {
52+ urls [counter ] = key
53+ counter ++
54+ }
55+ return urls
56+ }
57+
2258// Watcher describes a component that watches for new certificates in a CT log.
2359type Watcher struct {
2460 Name string
@@ -132,6 +168,7 @@ func (w *worker) foundCertCallback(rawEntry *ct.RawLogEntry) {
132168 }
133169 entry .Data .UpdateType = "X509LogEntry"
134170 w .entryChan <- entry
171+ atomic .AddInt64 (& processedCerts , 1 )
135172}
136173
137174// foundPrecertCallback is the callback that handles cases where new precerts are found.
@@ -143,9 +180,10 @@ func (w *worker) foundPrecertCallback(rawEntry *ct.RawLogEntry) {
143180 }
144181 entry .Data .UpdateType = "PrecertLogEntry"
145182 w .entryChan <- entry
183+ atomic .AddInt64 (& processedPrecerts , 1 )
146184}
147185
148- // certHandler takes the entries out of the channel and broadcasts them to all clients.
186+ // certHandler takes the entries out of the entryChan channel and broadcasts them to all clients.
149187func certHandler (entryChan chan certstream.Entry ) {
150188 var processed int64
151189 for {
@@ -160,6 +198,12 @@ func certHandler(entryChan chan certstream.Entry) {
160198
161199 // Run json encoding in the background and send the result to the clients.
162200 web .ClientHandler .Broadcast <- entry
201+
202+ url := normalizeCtlogURL (entry .Data .Source .URL )
203+
204+ urlMapMutex .Lock ()
205+ urlMap [url ] += 1
206+ urlMapMutex .Unlock ()
163207 }
164208}
165209
@@ -199,3 +243,10 @@ func getAllLogs() (loglist3.LogList, error) {
199243
200244 return * allLogs , nil
201245}
246+
247+ func normalizeCtlogURL (input string ) string {
248+ input = strings .TrimPrefix (input , "http://" )
249+ input = strings .TrimPrefix (input , "https://" )
250+ input = strings .TrimSuffix (input , "/" )
251+ return input
252+ }
0 commit comments