certstream

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 18 Imported by: 1

README

CertStream

Small library wrapping github.com/google/certificate-transparency-go.

Adds no new dependencies.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHttpClient = &http.Client{
	Timeout: 10 * time.Second,
	Transport: &http.Transport{
		TLSHandshakeTimeout:   30 * time.Second,
		ResponseHeaderTimeout: 30 * time.Second,
		MaxIdleConnsPerHost:   10,
		DisableKeepAlives:     false,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	},
}

Functions

func DefaultLogStreamInit

func DefaultLogStreamInit(op *loglist3.Operator, log *loglist3.Log) (httpClient *http.Client, startIndex int64)

DefaultLogStreamInit returns (DefaultHttpClient, -1) for all operators and logs where the log is usable.

func GetLogList

func GetLogList(ctx context.Context, httpClient *http.Client, listUrl string) (logList *loglist3.LogList, err error)

GetLogList fetches a CT log list from the given listUrl. Usually you would pass loglist3.AllLogListURL for the listUrl.

func OperatorDomain

func OperatorDomain(urlString string) string

OperatorDomain returns the TLD+1 given an URL.

Types

type CertStream

type CertStream struct {
	LogStreamInit LogStreamInitFn
	BatchSize     int
	ParallelFetch int
	Operators     map[string]*LogOperator // operators by operator domain
}

func New

func New() *CertStream

New returns a CertStream with reasonable defaults.

func (*CertStream) CountStreams added in v0.0.3

func (cs *CertStream) CountStreams() (running, stopped int)

func (*CertStream) Start

func (cs *CertStream) Start(ctx context.Context, logList *loglist3.LogList) (entryCh <-chan *LogEntry, err error)

Start returns a channel to read results from. If logList is nil, we fetch the list from loglist3.AllLogListURL using DefaultHttpClient.

type LogEntry

type LogEntry struct {
	*LogStream
	Err          error           // error from RawLogEntryFromLeaf or ToLogEntry, or nil
	RawLogEntry  *ct.RawLogEntry // may be nil in case of error
	*ct.LogEntry                 // may be nil in case of error
}

func (*LogEntry) Cert

func (le *LogEntry) Cert() (cert *x509.Certificate)

Cert returns the cert from LogEntry.X509Cert or LogEntry.Precert.TBSCertificate, or nil.

func (*LogEntry) DNSNames

func (le *LogEntry) DNSNames() (names []string)

DNSNames returns Cert().DNSNames if possible.

func (*LogEntry) Index

func (le *LogEntry) Index() (index int64)

Index returns the log index or -1 if none is available.

func (*LogEntry) String

func (le *LogEntry) String() (s string)

type LogOperator added in v0.0.3

type LogOperator struct {
	*CertStream
	*loglist3.Operator
	Domain  string // e.g. "letsencrypt.org" or "googleapis.com"
	Count   int64  // atomic; sum of the stream's Count
	Streams []*LogStream
}

type LogStream

type LogStream struct {
	*LogOperator
	*loglist3.Log
	*client.LogClient
	Err      error // set if Stopped() returns true
	Count    int64 // atomic; number of certificates sent to the channel
	Index    int64 // atomic; highest index sent to the channel
	EndIndex int64 // atomic: highest index that was available on startup
	// contains filtered or unexported fields
}

func NewLogStream

func NewLogStream(logop *LogOperator, httpClient *http.Client, startIndex int64, log *loglist3.Log) (ls *LogStream, err error)

func (*LogStream) Run

func (ls *LogStream) Run(ctx context.Context, entryCh chan<- *LogEntry)

func (*LogStream) Stopped added in v0.0.3

func (ls *LogStream) Stopped() bool

func (*LogStream) String

func (ls *LogStream) String() string

type LogStreamInitFn

type LogStreamInitFn func(op *loglist3.Operator, log *loglist3.Log) (httpClient *http.Client, startIndex int64)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL