all: rework bootstrap IP discovering

At startup, ctrld gathers bootstrap IP information and use this
bootstrap IP for connecting to upstream. However, in case the network
stack changed, for example, dues to VPN connection, ctrld will still use
this old (maybe invalid) bootstrap IP for the current network stack.

This commit rework the discovering process, and re-initializing the
bootstrap IP if connecting to upstream failed.
This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2023-03-07 10:25:48 +07:00
1 parent 930a5ad439
commit 8b08cc8a6e
7 files changed
+95 -53

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ func resolve(ctx context.Context, msg *dns.Msg, endpoint string, tlsConfig *tls.
func doResolve(ctx context.Context, msg *dns.Msg, endpoint string, tlsConfig *tls.Config) (*dns.Msg, error) {
session, err := quic.DialAddr(endpoint, tlsConfig, nil)
if err != nil {
return nil, err
return nil, ErrUpstreamFailed
}
defer session.CloseWithError(quic.ApplicationErrorCode(quic.NoError), "")