Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertStream ¶
type CertStream struct {
// contains filtered or unexported fields
}
CertStream is a library interface for consuming CT logs directly
Example (SlowProcessing) ¶
Example showing slow processing with automatic backpressure
package main
import (
"log"
"time"
"github.com/letrics/certstream-server-go/pkg/certstream"
)
func main() {
cs := certstream.New()
certChan := cs.Start()
for cert := range certChan {
// Slow processing - maybe saving to database
log.Printf("Processing: %v\n", cert.Data.LeafCert.AllDomains)
// Simulate slow operation (e.g., database write, API call)
time.Sleep(1 * time.Second)
log.Println("Done!")
// The CT workers will automatically slow down to 1 cert/second
// to match your processing speed. No certificates are dropped!
}
}
func New ¶
func New() *CertStream
New creates a certstream library instance with default configuration
Example ¶
ExampleNew demonstrates basic usage with default configuration
package main
import (
"log"
"github.com/letrics/certstream-server-go/pkg/certstream"
)
func main() {
// Create a certstream instance with defaults
cs := certstream.New()
// Start consuming certificates
certChan := cs.Start()
// Process certificates - this loop runs at YOUR speed
// CT workers will automatically slow down to match your processing rate
for cert := range certChan {
// Your custom processing logic here
log.Printf("New certificate for domains: %v\n", cert.Data.LeafCert.AllDomains)
// The CT log workers will wait until you finish processing
// before sending the next certificate
}
}
func NewFromConfig ¶
func NewFromConfig(conf config.Config) *CertStream
NewFromConfig creates a certstream library instance with the provided config
func NewFromConfigFile ¶
func NewFromConfigFile(configPath string) (*CertStream, error)
NewFromConfigFile creates a certstream library instance from a config file
Example ¶
ExampleNewFromConfigFile demonstrates usage with a config file
package main
import (
"log"
"github.com/letrics/certstream-server-go/pkg/certstream"
)
func main() {
// Load configuration from file
cs, err := certstream.NewFromConfigFile("./config.yaml")
if err != nil {
log.Fatal(err)
}
// Start and consume
certChan := cs.Start()
for cert := range certChan {
processCertificate(cert)
}
}
// Helper function for examples
func processCertificate(cert certstream.Entry) {
log.Printf("Domains: %v\n", cert.Data.LeafCert.AllDomains)
}
func (*CertStream) EnableRecovery ¶
func (cs *CertStream) EnableRecovery(indexFilePath string)
EnableRecovery enables the recovery feature which allows resuming from the last processed certificate
Example ¶
ExampleCertStream_EnableRecovery shows how to enable recovery mode
package main
import (
"log"
"github.com/letrics/certstream-server-go/pkg/certstream"
)
func main() {
cs := certstream.New()
// Enable recovery to resume from last position after restart
cs.EnableRecovery("./ct_index.json")
// Adjust buffer sizes for your use case
cs.SetBufferSizes(1000, 5000)
certChan := cs.Start()
for cert := range certChan {
processCertificate(cert)
}
}
// Helper function for examples
func processCertificate(cert certstream.Entry) {
log.Printf("Domains: %v\n", cert.Data.LeafCert.AllDomains)
}
func (*CertStream) SetBufferSizes ¶
func (cs *CertStream) SetBufferSizes(ctLogBuffer, broadcastBuffer int)
SetBufferSizes configures the buffer sizes for the CT log fetching and certificate processing
func (*CertStream) Start ¶
func (cs *CertStream) Start() <-chan Entry
Start begins consuming CT logs. Returns a read-only channel you can consume from. This is non-blocking - the watcher runs in the background.
Usage:
cs := certstream.New()
certChan := cs.Start()
for cert := range certChan {
processCertificate(cert)
}
func (*CertStream) Stop ¶
func (cs *CertStream) Stop()
Stop gracefully stops the certstream and closes the certificate channel