Skip to content

Commit

Permalink
Suppress duplicate identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
AGWA committed Jul 28, 2016
1 parent 6cae494 commit 1f97fb3
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions identifiers.go
Expand Up @@ -143,12 +143,31 @@ func sanitizeUnicodeDNSName(value string) string {
}

func (ids *Identifiers) appendDNSName(dnsName string) {
if dnsName != "" {
if dnsName != "" && !ids.hasDNSName(dnsName) {
ids.DNSNames = append(ids.DNSNames, dnsName)
}
}
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) {
Expand Down

0 comments on commit 1f97fb3

Please sign in to comment.