Adds network id. Skips processing routes when router is the origin.

This commit is contained in:
Milos Gajdos
2019-08-27 23:08:35 +01:00
parent 470304ef87
commit 5e7208119e
8 changed files with 142 additions and 76 deletions

View File

@@ -7,9 +7,9 @@ import (
var (
// DefaultLink is default network link
DefaultLink = "local"
// DefaultLocalMetric is default route cost metric for the local network
// DefaultLocalMetric is default route cost for a local route
DefaultLocalMetric = 1
// DefaultNetworkMetric is default route cost metric for the micro network
// DefaultNetworkMetric is default route cost for a network route
DefaultNetworkMetric = 10
)
@@ -23,6 +23,8 @@ type Route struct {
Gateway string
// Network is network address
Network string
// Router is router id
Router string
// Link is network link
Link string
// Metric is the route cost metric
@@ -33,6 +35,6 @@ type Route struct {
func (r *Route) Hash() uint64 {
h := fnv.New64()
h.Reset()
h.Write([]byte(r.Service + r.Address + r.Gateway + r.Network + r.Link))
h.Write([]byte(r.Service + r.Address + r.Gateway + r.Network + r.Router + r.Link))
return h.Sum64()
}