1
0
mirror of https://github.com/fumiama/terasu.git synced 2026-06-30 09:40:24 +08:00

fix(dns): false-positive disable on deadline

This commit is contained in:
源文雨
2025-10-06 00:38:26 +08:00
parent fffef1be40
commit 812043a905

View File

@@ -132,8 +132,10 @@ func (ds *DNSList) lookupHostDoH(ctx context.Context, host string) (hosts []stri
return nil return nil
} }
} }
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
addr.disable(time.Hour) // no need to acquire write lock addr.disable(time.Hour) // no need to acquire write lock
} }
}
return nil // not found, fallback to ds.b return nil // not found, fallback to ds.b
}) })
if len(hosts) > 0 || err != nil { if len(hosts) > 0 || err != nil {
@@ -171,7 +173,7 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra
defer cancel() defer cancel()
} }
conn, err = dialer.DialContext(ctx, "tcp", addr.a) conn, err = dialer.DialContext(ctx, "tcp", addr.a)
if err != nil { if err != nil && !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
addr.disable(time.Hour) // no need to acquire write lock addr.disable(time.Hour) // no need to acquire write lock
continue continue
} }
@@ -181,8 +183,10 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra
return nil return nil
} }
_ = tlsConn.Close() _ = tlsConn.Close()
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
addr.disable(time.Hour) // no need to acquire write lock addr.disable(time.Hour) // no need to acquire write lock
} }
}
return nil return nil
}) })
return return