Only hash address if its a local route

This commit is contained in:
Asim Aslam 2019-09-20 09:40:55 +01:00
parent 66769e671f
commit f13887f604

View File

@ -658,13 +658,22 @@ func (n *network) advertise(client transport.Client, advertChan <-chan *router.A
// create a proto advert
var events []*pbRtr.Event
for _, event := range advert.Events {
// the routes service address
address := event.Route.Address
// only hash the address if we're advertising our own local routes
if event.Route.Router == advert.Id {
// hash the service before advertising it
hasher.Reset()
hasher.Write([]byte(event.Route.Address + n.node.id))
// NOTE: we override Gateway, Link and Service here
address = fmt.Sprintf("%d", hasher.Sum64())
}
// NOTE: we override Gateway, Link and Address here
// TODO: should we avoid overriding gateway?
route := &pbRtr.Route{
Service: event.Route.Service,
Address: fmt.Sprintf("%d", hasher.Sum64()),
Address: address,
Gateway: n.node.id,
Network: event.Route.Network,
Router: event.Route.Router,