mirror of
https://github.com/slackhq/nebula.git
synced 2025-12-06 02:30:57 -08:00
Remove WriteRaw, cidrTree -> routeTree to better describe its purpose, remove redundancy from field names (#582)
This commit is contained in:
parent
467e605d5e
commit
78d0d46bae
15 changed files with 137 additions and 204 deletions
|
|
@ -4,8 +4,10 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/slackhq/nebula/cidr"
|
||||
"github.com/slackhq/nebula/config"
|
||||
)
|
||||
|
||||
|
|
@ -16,6 +18,20 @@ type Route struct {
|
|||
Via *net.IP
|
||||
}
|
||||
|
||||
func makeRouteTree(routes []Route, allowMTU bool) (*cidr.Tree4, error) {
|
||||
routeTree := cidr.NewTree4()
|
||||
for _, r := range routes {
|
||||
if !allowMTU && r.MTU > 0 {
|
||||
return nil, fmt.Errorf("route MTU is not supported in %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
if r.Via != nil {
|
||||
routeTree.AddCIDR(r.Cidr, r.Via)
|
||||
}
|
||||
}
|
||||
return routeTree, nil
|
||||
}
|
||||
|
||||
func parseRoutes(c *config.C, network *net.IPNet) ([]Route, error) {
|
||||
var err error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue