add router handler & connector
This commit is contained in:
+3
-1
@@ -252,7 +252,9 @@ type SDConfig struct {
|
||||
}
|
||||
|
||||
type RouterRouteConfig struct {
|
||||
Net string `json:"net"`
|
||||
// Deprecated: use dst instead
|
||||
Net string `yaml:",omitempty" json:"net,omitempty"`
|
||||
Dst string `yaml:",omitempty" json:"dst,omitempty"`
|
||||
Gateway string `json:"gateway"`
|
||||
}
|
||||
|
||||
|
||||
@@ -46,17 +46,23 @@ func ParseRouter(cfg *config.RouterConfig) router.Router {
|
||||
var routes []*router.Route
|
||||
for _, route := range cfg.Routes {
|
||||
_, ipNet, _ := net.ParseCIDR(route.Net)
|
||||
if ipNet == nil {
|
||||
continue
|
||||
dst := route.Dst
|
||||
if dst != "" {
|
||||
_, ipNet, _ = net.ParseCIDR(dst)
|
||||
} else {
|
||||
if ipNet != nil {
|
||||
dst = ipNet.String()
|
||||
}
|
||||
}
|
||||
gw := net.ParseIP(route.Gateway)
|
||||
if gw == nil {
|
||||
|
||||
if dst == "" || route.Gateway == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
routes = append(routes, &router.Route{
|
||||
Net: ipNet,
|
||||
Gateway: gw,
|
||||
Dst: dst,
|
||||
Gateway: route.Gateway,
|
||||
})
|
||||
}
|
||||
opts := []xrouter.Option{
|
||||
|
||||
Reference in New Issue
Block a user