Merge pull request #773 from micro/net-hash
Only hash address if its a local route
This commit is contained in:
commit
46450ba507
@ -658,13 +658,22 @@ func (n *network) advertise(client transport.Client, advertChan <-chan *router.A
|
|||||||
// create a proto advert
|
// create a proto advert
|
||||||
var events []*pbRtr.Event
|
var events []*pbRtr.Event
|
||||||
for _, event := range advert.Events {
|
for _, event := range advert.Events {
|
||||||
// hash the service before advertising it
|
// the routes service address
|
||||||
hasher.Reset()
|
address := event.Route.Address
|
||||||
hasher.Write([]byte(event.Route.Address + n.node.id))
|
|
||||||
// NOTE: we override Gateway, Link and Service here
|
// 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))
|
||||||
|
address = fmt.Sprintf("%d", hasher.Sum64())
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: we override Gateway, Link and Address here
|
||||||
|
// TODO: should we avoid overriding gateway?
|
||||||
route := &pbRtr.Route{
|
route := &pbRtr.Route{
|
||||||
Service: event.Route.Service,
|
Service: event.Route.Service,
|
||||||
Address: fmt.Sprintf("%d", hasher.Sum64()),
|
Address: address,
|
||||||
Gateway: n.node.id,
|
Gateway: n.node.id,
|
||||||
Network: event.Route.Network,
|
Network: event.Route.Network,
|
||||||
Router: event.Route.Router,
|
Router: event.Route.Router,
|
||||||
|
Loading…
Reference in New Issue
Block a user