func (r SystemResolver) Address() string {
	return ""
}
Address implements Resolver.Address
package selfcensor
import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"log"
	"net"
	"sync"
	"time"
	"github.com/ooni/probe-engine/atomicx"
)
type Spec struct {
	PoisonSystemDNS map[string][]string
	BlockedEndpoints map[string]string
	BlockedFingerprints map[string]string
}
var (
	attempts *atomicx.Int64 = atomicx.NewInt64()
	enabled  *atomicx.Int64 = atomicx.NewInt64()
	mu       sync.Mutex
	spec     *Spec
)
func Enabled() bool {
	return enabled.Load() != 0
}
func Attempts() int64 {
	return attempts.Load()
}
func Enable(data string) error {
	mu.Lock()
	defer mu.Unlock()
	s := new(Spec)
	if err := json.Unmarshal([]byte(data), s); err != nil {
		return err
	}
	spec = s
	enabled.Add(1)
	log.Printf("selfcensor: spec %+v", *spec)
	return nil
}
func MaybeEnable(data string) (err error) {
	if data != "" {
		err = Enable(data)
	}
	return
}
type SystemResolver struct{}
var errTimeout = errors.New("i/o timeout")
func (r SystemResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
	if enabled.Load() != 0 {  
		mu.Lock()
		defer mu.Unlock()
		attempts.Add(1)
		if spec.PoisonSystemDNS != nil {
			values := spec.PoisonSystemDNS[hostname]
			if len(values) == 1 && values[0] == "NXDOMAIN" {
				return nil, errors.New("no such host")
			}
			if len(values) == 1 && values[0] == "TIMEOUT" {
				return nil, errTimeout
			}
			if len(values) > 0 {
				return values, nil
			}
		}
	}
	return net.DefaultResolver.LookupHost(ctx, hostname)
}
func (r SystemResolver) Network() string {
	return "system"
}