+ // It would be better if dial rate limiting could be tested when considering to open connections
+ // instead. Doing it here means if the limit is low, and the half-open limit is high, we could
+ // end up with lots of outgoing connection attempts pending that were initiated on stale data.
+ {
+ dialReservation := cl.config.DialRateLimiter.Reserve()
+ if !opts.receivedHolepunchConnect {
+ if !dialReservation.OK() {
+ err = errors.New("can't make dial limit reservation")
+ return
+ }
+ time.Sleep(dialReservation.Delay())
+ }
+ }