This commit is contained in:
Adam Ierymenko 2019-09-25 14:16:55 -07:00
parent 9c37fc1a5f
commit 570032484f
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
9 changed files with 93 additions and 103 deletions

View file

@ -33,6 +33,14 @@ type Route struct {
Metric uint16
}
// String returns a string representation of this route
func (r *Route) String() string {
if len(r.Via) == 0 {
return r.Target.String() + "->LAN"
}
return r.Target.String() + "->" + r.Via.String()
}
// key generates a key suitable for a map[] from this route
func (r *Route) key() (k [6]uint64) {
copy(((*[16]byte)(unsafe.Pointer(&k[0])))[:], r.Target.IP)