1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

fix fakedns instance resolution leak by avoid using require

This commit is contained in:
Shelikhoo 2022-01-09 22:45:50 +00:00 committed by Xiaokang Wang (Shelikhoo)
parent a10f7b320f
commit 17a5aaebe2

View File

@ -17,12 +17,13 @@ import (
// newFakeDNSSniffer Creates a Fake DNS metadata sniffer
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
var fakeDNSEngine dns.FakeDNSEngine
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
fakeDNSEngine = fdns
})
if err != nil {
return protocolSnifferWithMetadata{}, err
{
fakeDNSEngineFeat := core.MustFromContext(ctx).GetFeature(fakeDNSEngine)
if fakeDNSEngineFeat != nil {
fakeDNSEngine = fakeDNSEngineFeat.(dns.FakeDNSEngine)
}
}
if fakeDNSEngine == nil {
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
return protocolSnifferWithMetadata{}, errNotInit