mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:14:01 +03:00
FILE / ScuroNeko/mtg
mtglib/internal/doppel/scout_conn_collected_test.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).
43 lines
992 B
Go
43 lines
992 B
Go
package doppel
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/9seconds/mtg/v2/mtglib/internal/tls"
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type ScoutConnCollectedTestSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func (suite *ScoutConnCollectedTestSuite) TestAddSingle() {
|
|
collected := NewScoutConnCollected()
|
|
collected.Add(tls.TypeApplicationData, 100)
|
|
|
|
suite.Len(collected.data, 1)
|
|
suite.Equal(byte(tls.TypeApplicationData), collected.data[0].recordType)
|
|
}
|
|
|
|
func (suite *ScoutConnCollectedTestSuite) TestAddTimestampsAreMonotonic() {
|
|
collected := NewScoutConnCollected()
|
|
|
|
collected.Add(tls.TypeApplicationData, 100)
|
|
|
|
time.Sleep(time.Microsecond)
|
|
collected.Add(tls.TypeApplicationData, 100)
|
|
|
|
time.Sleep(time.Microsecond)
|
|
collected.Add(tls.TypeApplicationData, 100)
|
|
|
|
for i := 1; i < len(collected.data); i++ {
|
|
suite.True(collected.data[i].timestamp.After(collected.data[i-1].timestamp))
|
|
}
|
|
}
|
|
|
|
func TestScoutConnCollected(t *testing.T) {
|
|
t.Parallel()
|
|
suite.Run(t, &ScoutConnCollectedTestSuite{})
|
|
}
|