func (p *Proxy) Stop() error {
	log.Println("Stopping the DNS proxy server")

	p.Lock()
	defer p.Unlock()
	if !p.started {
		log.Println("The DNS proxy server is not started")
		return nil
	}

	var err error

	if p.tcpListen != nil {
		err = p.tcpListen.Close()
		p.tcpListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close TCP listening socket")
		}
	}

	if p.udpListen != nil {
		err = p.udpListen.Close()
		p.udpListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close UDP listening socket")
		}
	}

	if p.tlsListen != nil {
		err = p.tlsListen.Close()
		p.tlsListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close TLS listening socket")
		}
	}

	if p.httpsServer != nil {
		err = p.httpsServer.Close()
		p.httpsListen = nil
		p.httpsServer = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close HTTPS server")
		}
	}

	p.started = false
	log.Println("Stopped the DNS proxy server")
	return nil
}
// Stop stops the proxy server including all its listeners
Stop stops the proxy server including all its listeners
// Stop stops the proxy server including all its listeners
func (p *Proxy) Stop() error {
	log.Println("Stopping the DNS proxy server")
	p.Lock()
	defer p.Unlock()
	if !p.started {
		log.Println("The DNS proxy server is not started")
		return nil
	}
	var err error
	if p.tcpListen != nil {
		err = p.tcpListen.Close()
		p.tcpListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close TCP listening socket")
		}
	}
	if p.udpListen != nil {
		err = p.udpListen.Close()
		p.udpListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close UDP listening socket")
		}
	}
	if p.tlsListen != nil {
		err = p.tlsListen.Close()
		p.tlsListen = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close TLS listening socket")
		}
	}
	if p.httpsServer != nil {
		err = p.httpsServer.Close()
		p.httpsListen = nil
		p.httpsServer = nil
		if err != nil {
			return errorx.Decorate(err, "couldn't close HTTPS server")
		}
	}
	p.started = false
	log.Println("Stopped the DNS proxy server")
	return nil
}
func ( p * Proxy ) Stop ( ) error { log . Println ( " " ) p . Lock ( ) defer p . Unlock ( ) if ! p . started { log . Println ( " " ) return nil } var err error if p . tcpListen != nil { err = p . tcpListen . Close ( ) p . tcpListen = nil if err != nil { return errorx . Decorate ( err , " " ) } } if p . udpListen != nil { err = p . udpListen . Close ( ) p . udpListen = nil if err != nil { return errorx . Decorate ( err , " " ) } } if p . tlsListen != nil { err = p . tlsListen . Close ( ) p . tlsListen = nil if err != nil { return errorx . Decorate ( err , " " ) } } if p . httpsServer != nil { err = p . httpsServer . Close ( ) p . httpsListen = nil p . httpsServer = nil if err != nil { return errorx . Decorate ( err , " " ) } } p . started = false log . Println ( " " ) return nil }
Stop stops the proxy server including all its listeners
Stop stops the proxy server including all its listeners