func newTestServer(t *testing.T, c bool) *server {
	Port += 10
	StrPort = strconv.Itoa(Port)
	s := new(server)
	client := etcd.NewClient([]string{"http://127.0.0.1:4001"})
	client.SyncCluster()

	// TODO(miek): why don't I use NewServer??
	s.group = new(sync.WaitGroup)
	s.client = client
	s.scache = cache.New(100, 0)
	s.rcache = cache.New(100, 0)
	if c {
		s.rcache = cache.New(100, 60) // 100 items, 60s ttl
	}
	s.config = new(Config)
	s.config.Domain = "skydns.test."
	s.config.DomainLabels = 2
	s.config.DnsAddr = "127.0.0.1:" + StrPort
	s.config.Nameservers = []string{"8.8.4.4:53"}
	setDefaults(s.config)
	s.config.Local = "104.server1.development.region1.skydns.test."
	s.config.Priority = 10
	s.config.RCacheTtl = RCacheTtl
	s.config.Ttl = 3600
	s.config.Ndots = 2
	s.config.log = log.New("skydns", false, log.NullSink())
	s.dnsUDPclient = &dns.Client{Net: "udp", ReadTimeout: 2 * s.config.ReadTimeout, WriteTimeout: 2 * s.config.ReadTimeout, SingleInflight: true}
	s.dnsTCPclient = &dns.Client{Net: "tcp", ReadTimeout: 2 * s.config.ReadTimeout, WriteTimeout: 2 * s.config.ReadTimeout, SingleInflight: true}

	go s.Run()
	return s
}
func loadConfig(client *etcd.Client, config *Config) (*Config, error) {
	config.log = log.New("skydns", false,
		log.CombinedSink(os.Stderr, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

	// Override wat isn't set yet from the command line.
	n, err := client.Get("/skydns/config", false, false)
	if err != nil {
		config.log.Info("falling back to default configuration, could not read from etcd:", err)
		if err := setDefaults(config); err != nil {
			return nil, err
		}
		return config, nil
	}
	if err := json.Unmarshal([]byte(n.Node.Value), &config); err != nil {
		return nil, err
	}
	if err := setDefaults(config); err != nil {
		return nil, err
	}
	return config, nil
}
Beispiel #3
0
func LoadConfig(client *etcd.Client) (*Config, error) {
	config := &Config{ReadTimeout: 0, Domain: "", DnsAddr: "", DNSSEC: ""}
	config.log = log.New("skydns", false,
		log.CombinedSink(os.Stderr, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

	n, err := client.Get("/skydns/config", false, false)
	if err != nil {
		config.log.Info("falling back to default configuration")
		if err := setDefaults(config); err != nil {
			return nil, err
		}
		return config, nil
	}
	if err := json.Unmarshal([]byte(n.Node.Value), &config); err != nil {
		return nil, err
	}
	if err := setDefaults(config); err != nil {
		return nil, err
	}
	return config, nil
}
Beispiel #4
0
func newTestServer(t *testing.T) *server {
	Port += 10
	StrPort = strconv.Itoa(Port)
	s := new(server)
	client := etcd.NewClient([]string{"http://127.0.0.1:4001"})
	client.SyncCluster()

	s.group = new(sync.WaitGroup)
	s.client = client
	s.config = new(Config)
	s.config.DnsAddr = "127.0.0.1:" + StrPort
	s.config.Nameservers = []string{"8.8.4.4:53"}
	s.config.Domain = "skydns.test."
	s.config.Hostmaster = "hostmaster.skydns.test."
	s.config.DomainLabels = 2
	s.config.Priority = 10
	s.config.Ttl = 3600
	s.config.log = log.New("skydns", false, log.NullSink())
	go s.Run()
	return s
}
Beispiel #5
0
package log

import (
	golog "github.com/coreos/go-log/log"
	"os"
)

// The Verbose flag turns on verbose logging.
var Verbose bool = false

var logger *golog.Logger = golog.New("etcd", false,
	golog.CombinedSink(os.Stdout, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

func Infof(format string, v ...interface{}) {
	logger.Infof(format, v...)
}

func Debugf(format string, v ...interface{}) {
	if Verbose {
		logger.Debugf(format, v...)
	}
}

func Debug(v ...interface{}) {
	if Verbose {
		logger.Debug(v...)
	}
}

func Warnf(format string, v ...interface{}) {
	logger.Warningf(format, v...)
Beispiel #6
0
func NewLogger(prefix string, verbose bool, sinks ...log.Sink) *Logger {
	return &Logger{
		Logger: log.New(prefix, verbose, sinks...),
		sinks:  sinks,
	}
}