Skip to content

Commit

Permalink
Only vet unvetted masquerades, and do it in series
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed May 31, 2023
1 parent 13856a1 commit 04f7265
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ func (fctx *FrontingContext) ConfigureWithHello(pool *x509.CertPool, providers m
}

d.loadCandidates(d.providers)
d.vet(numberToVetInitially)
if cacheFile != "" {
d.initCaching(cacheFile)
}
go d.vet(numberToVetInitially)
fctx.instance.Set(d)
return nil
}
Expand Down
12 changes: 9 additions & 3 deletions direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,23 @@ func vet(m *Masquerade, pool *x509.CertPool, testURL string) bool {
}

func (d *direct) vet(numberToVet int) {
log.Debugf("Vetting %d initial candidates in parallel", numberToVet)
log.Debugf("Vetting %d initial candidates in series", numberToVet)
for i := 0; i < numberToVet; i++ {
go d.vetOne()
d.vetOne()
}
}

func (d *direct) vetOne() {
// We're just testing the ability to connect here, destination site doesn't
// really matter
log.Trace("Vetting one")
conn, m, masqueradeGood, err := d.dialWith(context.Background(), d.masquerades)
unvettedMasquerades := make([]*masquerade, 0, len(d.masquerades))
for _, m := range d.masquerades {
if m.lastSucceeded().IsZero() {
unvettedMasquerades = append(unvettedMasquerades, m)
}
}
conn, m, masqueradeGood, err := d.dialWith(context.Background(), unvettedMasquerades)
if err != nil {
log.Errorf("unexpected error vetting masquerades: %v", err)
}
Expand Down

0 comments on commit 04f7265

Please sign in to comment.