Пример #1
0
func (p *Parser) Exec(d domains.Domain) ([]records.Record, error) {
	out, err := exec.Command("dig", "all", d.String()).Output()
	if err != nil {
		return []records.Record{}, err
	}
	date := time.Now()
	origin := d.TLD.Name + "."
	lines := strings.Split(strings.ToLower(string(out)), "\n")
	results := make([]records.Record, 0)
	for _, line := range lines {
		if len(line) == 0 || line[0] == ';' {
			continue
		}
		rr, err := records.New(line, origin, d.TLD, 86400, date, 0)
		if err != nil {
			log.Error("%s: %s", line, err)
			continue
		}
		err = rr.Insert()
		if err != nil {
			//log.Error("%s: %s", line, err)
			continue
		}
		results = append(results, rr)
	}
	return results, nil
}
Пример #2
0
func (p *Parser) handleLine(line string) {
	rr, err := records.New(line, p.origin, p.TLD, p.ttl, p.Date, p.ID)
	if err != nil {
		log.Warn("handleLine:getRecord: %s", err)
		log.Warn("handleLine:line: %s", line)
		return
	}
	rr.Parser = p.Parser
	err = p.domainInsert.Add(&rr.Domain)
	if err != nil {
		log.Error("handleLine: Unable to bulk insert Domain: %s", err)
		return
	}
	err = p.recordInsert.Add(&rr)
	if err != nil {
		log.Error("handleLine:recordInsert.Add: %s", err)
		return
	}
	p.recordTypes[rr.Type.Name] = rr.Type.ID
}