all: force re-bootstrapping with timeout error

This commit is contained in:
Cuong Manh Le
2023-12-08 23:23:33 +07:00
committed by Cuong Manh Le
parent e92619620d
commit 684019c2e3
2 changed files with 9 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"encoding/hex"
"errors"
"fmt"
"net"
"net/netip"
@@ -438,6 +439,11 @@ func (p *prog) proxy(ctx context.Context, req *proxyRequest) *dns.Msg {
go p.um.checkUpstream(upstreams[n], upstreamConfig)
}
}
// For timeout error (i.e: context deadline exceed), force re-bootstrapping.
var e net.Error
if errors.As(err, &e) && e.Timeout() {
upstreamConfig.ReBootstrap()
}
return nil
}
return answer