[#607] network: Do not use Address.String for address comparison

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-16 15:03:11 +03:00 committed by Leonard Lyubich
parent dd67e2b690
commit e5504c7130
6 changed files with 24 additions and 15 deletions

View file

@ -218,16 +218,16 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
addr := srv.Address()
if r.loadAddrSrc.LocalAddress().String() == srv.Address() {
// if local => return no-op writer
return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil
}
netAddr, err := network.AddressFromString(addr)
if err != nil {
return nil, fmt.Errorf("could not convert address to IP format: %w", err)
}
if network.IsLocalAddress(r.loadAddrSrc, *netAddr) {
// if local => return no-op writer
return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil
}
c, err := r.clientCache.Get(netAddr)
if err != nil {
return nil, fmt.Errorf("could not initialize API client: %w", err)