@@ -13,10 +13,11 @@ import (
1313 "sync/atomic"
1414 "time"
1515
16+ "github.com/google/trillian/client/backoff"
17+
1618 "github.com/d-Rickyy-b/certstream-server-go/internal/config"
1719 "github.com/d-Rickyy-b/certstream-server-go/internal/models"
1820 "github.com/d-Rickyy-b/certstream-server-go/internal/web"
19- "github.com/google/trillian/client/backoff"
2021
2122 ct "github.com/google/certificate-transparency-go"
2223 "github.com/google/certificate-transparency-go/client"
@@ -569,7 +570,7 @@ func (w *worker) foundPrecertCallback(rawEntry *ct.RawLogEntry) {
569570// certHandler takes the entries out of the entryChan channel and broadcasts them to all clients.
570571// Only a single instance of the certHandler runs per certstream server.
571572func certHandler (entryChan chan models.Entry ) {
572- var processed int64
573+ var processed uint64
573574
574575 for {
575576 entry := <- entryChan
@@ -634,10 +635,11 @@ func getAllLogs() (loglist3.LogList, error) {
634635 }
635636
636637 // Add manually added logs from config to the allLogs list
637- if config .AppConfig .General .AdditionalLogs == nil {
638- return allLogs , nil
639- }
638+ // if config.AppConfig.General.AdditionalLogs == nil {
639+ // return allLogs, nil
640+ // }
640641
642+ logFound:
641643 for _ , additionalLog := range config .AppConfig .General .AdditionalLogs {
642644 customLog := loglist3.Log {
643645 URL : additionalLog .URL ,
@@ -647,10 +649,16 @@ func getAllLogs() (loglist3.LogList, error) {
647649 operatorFound := false
648650 for _ , operator := range allLogs .Operators {
649651 if operator .Name == additionalLog .Operator {
650- // TODO Check if the log is already in the list
651- operator .Logs = append (operator .Logs , & customLog )
652652 operatorFound = true
653653
654+ for _ , ctlog := range operator .Logs {
655+ if ctlog .URL == additionalLog .URL {
656+ // Log already exists, skip it.
657+ break logFound
658+ }
659+ }
660+ // This works, since allLogs.Operators is a slice of pointers.
661+ operator .Logs = append (operator .Logs , & customLog )
654662 break
655663 }
656664 }
@@ -664,6 +672,39 @@ func getAllLogs() (loglist3.LogList, error) {
664672 }
665673 }
666674
675+ for _ , additionalLog := range config .AppConfig .General .AdditionalTiledLogs {
676+ customLog := loglist3.TiledLog {
677+ MonitoringURL : additionalLog .URL ,
678+ Description : additionalLog .Description ,
679+ }
680+
681+ operatorFound := false
682+
683+ tiledLogFound:
684+ for _ , operator := range allLogs .Operators {
685+ if operator .Name == additionalLog .Operator {
686+ operatorFound = true
687+ for _ , tl := range operator .TiledLogs {
688+ if tl .MonitoringURL == additionalLog .URL {
689+ // Log already exists, skip it.
690+ break tiledLogFound
691+ }
692+ }
693+ // This works, since allLogs.Operators is a slice of pointers.
694+ operator .TiledLogs = append (operator .TiledLogs , & customLog )
695+ break
696+ }
697+ }
698+
699+ if ! operatorFound {
700+ newOperator := loglist3.Operator {
701+ Name : additionalLog .Operator ,
702+ TiledLogs : []* loglist3.TiledLog {& customLog },
703+ }
704+ allLogs .Operators = append (allLogs .Operators , & newOperator )
705+ }
706+ }
707+
667708 return allLogs , nil
668709}
669710
0 commit comments