@@ -679,22 +679,11 @@ func nodesAreEqual(a, b *Node) bool {
679679 if a == b {
680680 return true
681681 }
682- if ! (a .Endpoint != nil ) == (b .Endpoint != nil ) {
682+ // Check the DNS name first since this package
683+ // is doing the DNS resolution.
684+ if ! a .Endpoint .Equal (b .Endpoint , true ) {
683685 return false
684686 }
685- if a .Endpoint != nil {
686- if a .Endpoint .Port != b .Endpoint .Port {
687- return false
688- }
689- // Check the DNS name first since this package
690- // is doing the DNS resolution.
691- if a .Endpoint .DNS != b .Endpoint .DNS {
692- return false
693- }
694- if a .Endpoint .DNS == "" && ! a .Endpoint .IP .Equal (b .Endpoint .IP ) {
695- return false
696- }
697- }
698687 // Ignore LastSeen when comparing equality we want to check if the nodes are
699688 // equivalent. However, we do want to check if LastSeen has transitioned
700689 // between valid and invalid.
@@ -708,22 +697,11 @@ func peersAreEqual(a, b *Peer) bool {
708697 if a == b {
709698 return true
710699 }
711- if ! (a .Endpoint != nil ) == (b .Endpoint != nil ) {
700+ // Check the DNS name first since this package
701+ // is doing the DNS resolution.
702+ if ! a .Endpoint .Equal (b .Endpoint , true ) {
712703 return false
713704 }
714- if a .Endpoint != nil {
715- if a .Endpoint .Port != b .Endpoint .Port {
716- return false
717- }
718- // Check the DNS name first since this package
719- // is doing the DNS resolution.
720- if a .Endpoint .DNS != b .Endpoint .DNS {
721- return false
722- }
723- if a .Endpoint .DNS == "" && ! a .Endpoint .IP .Equal (b .Endpoint .IP ) {
724- return false
725- }
726- }
727705 if len (a .AllowedIPs ) != len (b .AllowedIPs ) {
728706 return false
729707 }
@@ -778,7 +756,7 @@ func discoveredEndpointsAreEqual(a, b map[string]*wireguard.Endpoint) bool {
778756 return false
779757 }
780758 for k := range a {
781- if ! a [k ].Equal (b [k ]) {
759+ if ! a [k ].Equal (b [k ], false ) {
782760 return false
783761 }
784762 }
@@ -802,17 +780,17 @@ func discoverNATEndpoints(nodes map[string]*Node, peers map[string]*Peer, conf *
802780 }
803781 for _ , n := range nodes {
804782 if peer , ok := keys [string (n .Key )]; ok && n .PersistentKeepalive > 0 {
805- level .Debug (logger ).Log ("msg" , "WireGuard Update NAT Endpoint" , "node" , n .Name , "endpoint" , peer .Endpoint , "former-endpoint" , n .Endpoint , "same" , n .Endpoint .Equal (peer .Endpoint ))
783+ level .Debug (logger ).Log ("msg" , "WireGuard Update NAT Endpoint" , "node" , n .Name , "endpoint" , peer .Endpoint , "former-endpoint" , n .Endpoint , "same" , n .Endpoint .Equal (peer .Endpoint , false ))
806784 // Should check location leader but only available in topology ... or have topology handle that list
807785 // Better check wg latest-handshake
808- if ! n .Endpoint .Equal (peer .Endpoint ) {
786+ if ! n .Endpoint .Equal (peer .Endpoint , false ) {
809787 natEndpoints [string (n .Key )] = peer .Endpoint
810788 }
811789 }
812790 }
813791 for _ , p := range peers {
814792 if peer , ok := keys [string (p .PublicKey )]; ok && p .PersistentKeepalive > 0 {
815- if ! p .Endpoint .Equal (peer .Endpoint ) {
793+ if ! p .Endpoint .Equal (peer .Endpoint , false ) {
816794 natEndpoints [string (p .PublicKey )] = peer .Endpoint
817795 }
818796 }
0 commit comments