fea: switch: support router network

This commit is contained in:
Daniel Ding
2023-09-26 15:30:04 +08:00
parent baec14f05e
commit a15a737e2c
11 changed files with 356 additions and 158 deletions

View File

@@ -10,6 +10,7 @@ type Subnet struct {
Start string `json:"startAt,omitempty"`
End string `json:"endAt,omitempty"`
Netmask string `json:"netmask,omitempty"`
CIDR string `json:"cidr,omitempty"`
}
type MultiPath struct {
@@ -44,6 +45,20 @@ func (r *PrefixRoute) String() string {
return fmt.Sprintf("{%s}", strings.Join(elems, " "))
}
func CorrectRoutes(routes []PrefixRoute, nexthop string) {
for i := range routes {
if routes[i].Metric == 0 {
routes[i].Metric = 660
}
if routes[i].NextHop == "" {
routes[i].NextHop = nexthop
}
if routes[i].Mode == "" {
routes[i].Mode = "snat"
}
}
}
type HostLease struct {
Network string `json:"network,omitempty"`
Hostname string `json:"hostname"`