diff --git a/cmd/main_fakedns.go b/cmd/main_fakedns.go index 991b8f9..f6ed19b 100644 --- a/cmd/main_fakedns.go +++ b/cmd/main_fakedns.go @@ -18,15 +18,15 @@ func init() { registerInitFn(func() { if *args.EnableFakeDNS { - resolver, err := fakedns.NewResolver(*args.FakeDNSAddr, *args.Hosts, *args.BackendDNS) + var err error + fakeDNS, err = fakedns.NewResolver(*args.FakeDNSAddr, *args.Hosts, *args.BackendDNS) if err != nil { log.Fatalf("Create fake DNS server failed: %v", err) } - if err := resolver.Start(); err != nil { + if err := fakeDNS.Start(); err != nil { log.Fatalf("Start fake DNS failed: %v", err) } - fakeDNS = resolver } else { fakeDNS = nil }