Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

upgrade chaff lib, cap max chaff latency at 1000ms #1575

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/jackc/pgx/v4 v4.13.0
github.com/kelseyhightower/run v0.0.17
github.com/lstoll/awskms v0.0.0-20210310122415-d1696e9c112b
github.com/mikehelmick/go-chaff v0.5.0
github.com/mikehelmick/go-chaff v0.6.0
github.com/mitchellh/mapstructure v1.4.2
github.com/ory/dockertest v3.3.5+incompatible
github.com/rakutentech/jwk-go v1.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,8 @@ github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WT
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/mikehelmick/go-chaff v0.5.0 h1:u8lrTCbUsyVBFRHPs8Nn3i0830XAOrbcA5dbQl8tk78=
github.com/mikehelmick/go-chaff v0.5.0/go.mod h1:mFry3zNW17oxNGmZpQV3PEOmzTNyly3nLDYawCT/iCE=
github.com/mikehelmick/go-chaff v0.6.0 h1:RWn4tP+YI+MyCh+PsAyjr1zPFWpKX12Vzx1VXZYvcqk=
github.com/mikehelmick/go-chaff v0.6.0/go.mod h1:mFry3zNW17oxNGmZpQV3PEOmzTNyly3nLDYawCT/iCE=
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
Expand Down
4 changes: 4 additions & 0 deletions internal/publish/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ type Config struct {
StatsEmbargoPeriod time.Duration `env:"STATS_EMBARGO_PERIOD, default=48h"`
StatsResponsePaddingMinBytes int64 `env:"RESPONSE_PADDING_MIN_BYTES, default=2048"`
StatsResponsePaddingRange int64 `env:"RESPONSE_PADDING_RANGE, default=1024"`

// ChaffRequestMaxLatencyMS prevents chaff request from consistently increasing latency
// if the server is under abnormal load.
ChaffRequestMaxLatencyMS uint64 `env:"CHAFF_REQUEST_MAX_LATENCY_MS, default=1000"`
}

func (c *Config) MaintenanceMode() bool {
Expand Down
5 changes: 4 additions & 1 deletion internal/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ func NewServer(ctx context.Context, cfg *Config, env *serverenv.ServerEnv) (*Ser
return nil, fmt.Errorf("config validation: %w", err)
}

chaffer, err := chaff.NewTracker(chaff.NewJSONResponder(chaffPublishResponse), chaff.DefaultCapacity)
chaffer, err := chaff.NewTracker(
chaff.NewJSONResponder(chaffPublishResponse),
chaff.DefaultCapacity,
chaff.WithMaxLatency(cfg.ChaffRequestMaxLatencyMS))
if err != nil {
return nil, fmt.Errorf("error making chaffer: %w", err)
}
Expand Down