Remove WriteRaw, cidrTree -> routeTree to better describe its purpose, remove redundancy from field names (#582)

This commit is contained in:
Nate Brown 2021-11-12 12:47:09 -06:00 committed by GitHub
parent 467e605d5e
commit 78d0d46bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 137 additions and 204 deletions

View file

@ -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