func NewCfg(fname string, logger *dns.Logger) (c *Cfg, err error) {
	x := &Cfg{cfg: &Conf{}, logger: logger}
	if x.mfile, err = fileutil.NewGoMFile(fname, os.O_RDONLY, 0444, 0); err != nil {
		return
	}

	if err = x.cfg.Load(fname); err != nil {
		return
	}

	x.mfile.SetHandler(func(file *os.File) (err error) {
		if _, err = file.Seek(0, 0); err != nil {
			return
		}

		buf := []byte{}
		if buf, err = ioutil.ReadAll(file); err != nil {
			return
		}

		if err = x.cfg.LoadString(fname, string(buf)); err != nil {
			return
		}

		if logger.Level >= dns.LOG_EVENTS {
			logger.Log("loaded %q", fname)
			if logger.Level >= dns.LOG_DEBUG {
				logger.Log("\n%s", x.cfg)
			}
		}
		x.changed = true
		return
	})

	return x, nil
}
// NewCfg returns a newly created Cfg with resolv.Conf initialized from file fname of an Error of any.
// It binds the contained resolv.Conf to fname and on any changes to the fname file the Cfg resolv.Conf
// is reloaded on access via Cfg.Conf().
NewCfg returns a newly created Cfg with resolv.Conf initialized from file fname of an Error of any.
It binds the contained resolv.Conf to fname and on any changes to the fname file the Cfg resolv.Conf
is reloaded on access via Cfg.Conf().
// NewCfg returns a newly created Cfg with resolv . Conf initialized from file fname of an Error of any . // It binds the contained resolv . Conf to fname and on any changes to the fname file the Cfg resolv . Conf // is reloaded on access via Cfg . Conf () .
func NewCfg(fname string, logger *dns.Logger) (c *Cfg, err error) {
	x := &Cfg{cfg: &Conf{}, logger: logger}
	if x.mfile, err = fileutil.NewGoMFile(fname, os.O_RDONLY, 0444, 0); err != nil {
		return
	}
	if err = x.cfg.Load(fname); err != nil {
		return
	}
	x.mfile.SetHandler(func(file *os.File) (err error) {
		if _, err = file.Seek(0, 0); err != nil {
			return
		}
		buf := []byte{}
		if buf, err = ioutil.ReadAll(file); err != nil {
			return
		}
		if err = x.cfg.LoadString(fname, string(buf)); err != nil {
			return
		}
		if logger.Level >= dns.LOG_EVENTS {
			logger.Log("loaded %q", fname)
			if logger.Level >= dns.LOG_DEBUG {
				logger.Log("\n%s", x.cfg)
			}
		}
		x.changed = true
		return
	})
	return x, nil
}
func NewCfg ( fname string , logger * dns . Logger ) ( c * Cfg , err error ) { x := & Cfg { cfg : & Conf { } , logger : logger } if x . mfile , err = fileutil . NewGoMFile ( fname , os . O_RDONLY , 0444 , 0 ) ; err != nil { return } if err = x . cfg . Load ( fname ) ; err != nil { return } x . mfile . SetHandler ( func ( file * os . File ) ( err error ) { if _ , err = file . Seek ( 0 , 0 ) ; err != nil { return } buf := [ ] byte { } if buf , err = ioutil . ReadAll ( file ) ; err != nil { return } if err = x . cfg . LoadString ( fname , string ( buf ) ) ; err != nil { return } if logger . Level >= dns . LOG_EVENTS { logger . Log ( " " , fname ) if logger . Level >= dns . LOG_DEBUG { logger . Log ( " \n " , x . cfg ) } } x . changed = true return } ) return x , nil }
NewCfg returns a newly created Cfg with resolv.Conf initialized from file fname of an Error of any.
NewCfg returns a newly created Cfg with resolv . Conf initialized from file fname of an Error of any .