func (p *Proxy) Start() error {
	p.Lock()
	defer p.Unlock()

	log.Println("Starting the DNS proxy server")
	err := p.validateConfig()
	if err != nil {
		return err
	}

	if p.CacheEnabled {
		log.Printf("DNS cache is enabled")
		p.cache = &cache{}
	}

	if !p.AllServers {
		// set 0 as rtt initial value for each upstream to sort them after exchange
		p.upstreamsWithRtt = []upstreamWithRtt{}
		for _, u := range p.Upstreams {
			p.upstreamsWithRtt = append(p.upstreamsWithRtt, upstreamWithRtt{upstream: u, rtt: 0})
		}
	}

	err = p.startListeners()
	if err != nil {
		return err
	}

	p.started = true
	return nil
}
// Start initializes the proxy server and starts listening
Start initializes the proxy server and starts listening
// Start initializes the proxy server and starts listening
func (p *Proxy) Start() error {
	p.Lock()
	defer p.Unlock()
	log.Println("Starting the DNS proxy server")
	err := p.validateConfig()
	if err != nil {
		return err
	}
	if p.CacheEnabled {
		log.Printf("DNS cache is enabled")
		p.cache = &cache{}
	}
	if !p.AllServers {
		p.upstreamsWithRtt = []upstreamWithRtt{}
		for _, u := range p.Upstreams {
			p.upstreamsWithRtt = append(p.upstreamsWithRtt, upstreamWithRtt{upstream: u, rtt: 0})
		}
	}
	err = p.startListeners()
	if err != nil {
		return err
	}
	p.started = true
	return nil
}
func ( p * Proxy ) Start ( ) error { p . Lock ( ) defer p . Unlock ( ) log . Println ( " " ) err := p . validateConfig ( ) if err != nil { return err } if p . CacheEnabled { log . Printf ( " " ) p . cache = & cache { } } if ! p . AllServers { p . upstreamsWithRtt = [ ] upstreamWithRtt { } for _ , u := range p . Upstreams { p . upstreamsWithRtt = append ( p . upstreamsWithRtt , upstreamWithRtt { upstream : u , rtt : 0 } ) } } err = p . startListeners ( ) if err != nil { return err } p . started = true return nil }
Start initializes the proxy server and starts listening
Start initializes the proxy server and starts listening
// set 0 as rtt initial value for each upstream to sort them after exchange