Skip to content

Merge changes for 1.10 into master branch - #115

Merged
d-Rickyy-b merged 80 commits into
masterfrom
dev
Sep 12, 2026
Merged

d-Rickyy-b merged 80 commits into
masterfrom
dev

Conversation

@d-Rickyy-b

Copy link
Copy Markdown
Owner

Merge current changes from dev into master.

Previously, the real IP of the client was not properly handled by certstream-server-go. This commit takes the IP address from the header and stores them in the request context and the client struct. Additionally the user agent is now also preserved.

Also each client now gets a generated ID to identify it even if another client from the same IP connects to the server.

Also some log statements were changed so that it fits better when printing the client name.
Optimize tile processing by delaying the fetch of partial tiles. Certstream will wait up to a minute before forcefully fetching the partial tile to ensure slow-growing logs are still processed.

Certstream will now:
- Track when a partial tile is first seen
- Wait up to one minute before forcing a partial fetch
- Skip fetching partial tiles within the deferral window
- Reset tracking when a full tile was downloaded

fixes #104
references #97

Despite having worked fine on my machine, the report stated that they had issues downloading all certificates in time. This value might become configurable in the future.
fix(static-ct): defer partial tile fetching
Thought this was the build tag.
d-Rickyy-b and others added 29 commits July 7, 2026 01:50
Sends messages to the broker in batches to improve throughput. Messages are collected and flushed when a maximum batch size is reached or after a
configured wait time. This significantly reduces individual write calls.
Messages are also dropped if the client isn't connected.
The code for reading and validating the config grew quite big, so it made sense to split it up into multiple files and have a method called Valid() that checks for config validity on each individual struct.

In a further iteration we should split the config_test.go into multiple test files each testing only the respective individual files.
Made stream type configurable so that users can decide which stream they want to feed into kafka.
This should work well with a default kafka configuration. In the future this could become a config option.
Support for stream processing tools such as Kafka and NSQ
StaticCTClient.ctIndex was initialized to the checkpoint tree size (the
number of entries already seen) but then updated to the index of the last
processed entry, and the skip check treated it as the latter. The two
conventions are off by one, with three visible effects:

- Once caught up, currentTreeSize is always ctIndex+1, so the "no new
  entries" early return never fires. Every poll falls through to the
  partial tile logic, re-fetching a tile whose entries were all already
  processed. Before the deferral logic this happened on every poll,
  keeping the backoff reset; with the deferral logic it still happens
  once per maxPartialWait, forever, on idle logs.

- The first entry after a startup at the checkpoint size (index N when
  ctIndex was set to N) is skipped, since N <= N.

- Likewise, starting from a saved index of 0 skips entry 0.

Make ctIndex mean "index of the next entry to process" throughout: skip
entries with index < ctIndex, advance to entryIndex+1 after processing,
and start the full tile loop at ctIndex/TileSize. With that, the tree
size comparison is exact, a caught-up client does only the checkpoint
fetch per poll, and no entry is dropped at startup.

A saved recovery index written by the metrics package holds the last
processed entry index, so after this change resuming from it re-emits
that one entry, matching the behavior of the RFC 6962 scanner path
(which also uses the saved index as StartIndex).

Add tests that drive the client against an in-process static log and
check that entries are emitted exactly once, that an idle log causes no
tile fetches, and that the partial tile deferral still works.

Updates #104
Fix off-by-one is Static CT path causing refetches of non-growing logs
Enhances client robustness by:
- Making client resource cleanup safe from panics when internal channels are nil or closed repeatedly.
- Updating the unregistration process to use client objects directly for more reliable removal.
- Ensuring client internal channels are consistently initialized.
Without this, the worker would start at the last known ctIndex from when the worker was initially created as the ctIndex value does not get updated at runtime, since we're using the scanner implementation and our callbacks don't increment the ctIndex.

This fix prevents processing already processed certificates again, after a worker crashed.
@d-Rickyy-b
d-Rickyy-b merged commit 677305c into master Sep 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants