Suppress duplicate identifiers

This commit is contained in:
Andrew Ayer 2016-07-28 13:56:58 -07:00
parent 6cae4942e4
commit 1f97fb3a13
1 changed files with 21 additions and 2 deletions

View File

@ -143,12 +143,31 @@ func sanitizeUnicodeDNSName(value string) string {
} }
func (ids *Identifiers) appendDNSName(dnsName string) { func (ids *Identifiers) appendDNSName(dnsName string) {
if dnsName != "" { if dnsName != "" && !ids.hasDNSName(dnsName) {
ids.DNSNames = append(ids.DNSNames, dnsName) ids.DNSNames = append(ids.DNSNames, dnsName)
} }
} }
func (ids *Identifiers) appendIPAddress(ipaddr net.IP) { func (ids *Identifiers) appendIPAddress(ipaddr net.IP) {
ids.IPAddrs = append(ids.IPAddrs, ipaddr) if !ids.hasIPAddress(ipaddr) {
ids.IPAddrs = append(ids.IPAddrs, ipaddr)
}
}
func (ids *Identifiers) hasDNSName(target string) bool {
for _, value := range ids.DNSNames {
if value == target {
return true
}
}
return false
}
func (ids *Identifiers) hasIPAddress(target net.IP) bool {
for _, value := range ids.IPAddrs {
if value.Equal(target) {
return true
}
}
return false
} }
func (ids *Identifiers) addDnsSANfinal(value []byte) { func (ids *Identifiers) addDnsSANfinal(value []byte) {