mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
fix fakedns instance resolution leak by avoid using require
This commit is contained in:
parent
a10f7b320f
commit
17a5aaebe2
@ -17,12 +17,13 @@ import (
|
|||||||
// newFakeDNSSniffer Creates a Fake DNS metadata sniffer
|
// newFakeDNSSniffer Creates a Fake DNS metadata sniffer
|
||||||
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
||||||
var fakeDNSEngine dns.FakeDNSEngine
|
var fakeDNSEngine dns.FakeDNSEngine
|
||||||
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
{
|
||||||
fakeDNSEngine = fdns
|
fakeDNSEngineFeat := core.MustFromContext(ctx).GetFeature(fakeDNSEngine)
|
||||||
})
|
if fakeDNSEngineFeat != nil {
|
||||||
if err != nil {
|
fakeDNSEngine = fakeDNSEngineFeat.(dns.FakeDNSEngine)
|
||||||
return protocolSnifferWithMetadata{}, err
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if fakeDNSEngine == nil {
|
if fakeDNSEngine == nil {
|
||||||
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
|
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
|
||||||
return protocolSnifferWithMetadata{}, errNotInit
|
return protocolSnifferWithMetadata{}, errNotInit
|
||||||
|
Loading…
Reference in New Issue
Block a user