added fix in if statement to fix simple error when adding ipv6 address
This commit is contained in:
@@ -131,12 +131,11 @@ func (table *IpAddresses)RemoveDuplicates() error {
|
||||
for i, _:= range table.IpAddress {
|
||||
Exists := false
|
||||
for k := range NoDuplicates.IpAddress {
|
||||
if NoDuplicates.IpAddress[k].Ipv4 == table.IpAddress[i].Ipv4 || (NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6){
|
||||
if (NoDuplicates.IpAddress[k].Ipv4 != "" && NoDuplicates.IpAddress[k].Ipv4 == table.IpAddress[i].Ipv4) || (NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -65,3 +65,13 @@ func TestViewNetworkInterface(t *testing.T) {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIp4or6(t *testing.T) {
|
||||
// This test ensures that the ipv6 address gets detected
|
||||
test := "2001:8f8:172d:7e27:4f23:ae4:bce5:e037"
|
||||
res := Ip4or6(test)
|
||||
if res != "version 6" {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user