mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:34:02 +03:00
FILE / ScuroNeko/mtg
mtglib/internal/doppel/scout_conn_collected.go
Исходный файл и его история в репозитории.
Instead of a separate cert_probe.go that duplicates the scout's TLS connection logic, measure the cert chain size directly from the same HTTPS connections the scout already makes. Changes: - Extend ScoutConnResult with payloadLen field - Add Write interception to ScoutConn for handshake boundary detection - Scout.learn() now computes cert size (sum of ApplicationData between CCS and first client Write) alongside inter-record durations - Ganger aggregates cert sizes across raids and exposes NoiseParams() via atomic pointer for lock-free reads from proxy goroutines - Proxy reads NoiseParams from Ganger on each handshake instead of probing at startup - Remove cert_probe.go, disk cache, and related config options (noise-cache-path, noise-cache-ttl, noise-probe-count) Falls back to legacy 2500-4700 range until the first scout raid completes (typically within 1-2 seconds of startup).
41 lines
859 B
Go
41 lines
859 B
Go
package doppel
|
|
|
|
import "time"
|
|
|
|
const (
|
|
ScoutConnCollectedPreallocSize = 100
|
|
)
|
|
|
|
type ScoutConnResult struct {
|
|
timestamp time.Time
|
|
recordType byte
|
|
payloadLen int
|
|
}
|
|
|
|
type ScoutConnCollected struct {
|
|
data []ScoutConnResult
|
|
writeIndex int // index at which client first wrote post-handshake data; -1 if not set
|
|
}
|
|
|
|
func (s *ScoutConnCollected) Add(record byte, payloadLen int) {
|
|
s.data = append(s.data, ScoutConnResult{
|
|
timestamp: time.Now(),
|
|
recordType: record,
|
|
payloadLen: payloadLen,
|
|
})
|
|
}
|
|
|
|
// MarkWrite records the current data length as the handshake boundary.
|
|
func (s *ScoutConnCollected) MarkWrite() {
|
|
if s.writeIndex < 0 {
|
|
s.writeIndex = len(s.data)
|
|
}
|
|
}
|
|
|
|
func NewScoutConnCollected() *ScoutConnCollected {
|
|
return &ScoutConnCollected{
|
|
data: make([]ScoutConnResult, 0, ScoutConnCollectedPreallocSize),
|
|
writeIndex: -1,
|
|
}
|
|
}
|