@@ -900,30 +900,15 @@ func (s *Service) HandleHello(ownAddress, remoteAddress string, req *HelloReques
900
900
// ID already found, update peer data
901
901
for i , p := range s .myPeers .AllPeers {
902
902
if p .ID == req .SlaveID {
903
+ s .myPeers .AllPeers [i ].Port = req .SlavePort
903
904
if s .cfg .AllPortOffsetsUnique {
904
905
s .myPeers .AllPeers [i ].Address = slaveAddr
905
906
} else {
906
- // Need to check if this particular address does appear in
907
- // another peer, if so, we forbid to change the address:
908
- addrFound := false
909
- for j , pp := range s .myPeers .AllPeers {
910
- if j != i && pp .Address == slaveAddr {
911
- addrFound = true
912
- break
913
- }
914
- }
915
- // Slave address may not change in this case
916
- if addrFound && p .Address != slaveAddr {
907
+ // Slave address may not change
908
+ if p .Address != slaveAddr {
917
909
return ClusterConfig {}, maskAny (client .NewBadRequestError ("Cannot change slave address while using an existing ID." ))
918
910
}
919
- // We accept the new address (it might be the old one):
920
- s .myPeers .AllPeers [i ].Address = slaveAddr
921
- // However, since we also accept the port, we must set the
922
- // port ofset of that replaced peer to 0 such that the AllPeers
923
- // information actually contains the right port.
924
- s .myPeers .AllPeers [i ].PortOffset = 0
925
911
}
926
- s .myPeers .AllPeers [i ].Port = req .SlavePort
927
912
s .myPeers .AllPeers [i ].DataDir = req .DataDir
928
913
}
929
914
}
0 commit comments