mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 19:22:42 +08:00
强制使用规范的网络路由地址
This commit is contained in:
@@ -117,11 +117,18 @@ func SetGroup(g *Group) error {
|
||||
continue
|
||||
}
|
||||
|
||||
ipMask, _, err := parseIpNet(v.Val)
|
||||
ipMask, ipNet, err := parseIpNet(v.Val)
|
||||
|
||||
if err != nil {
|
||||
return errors.New("RouteInclude 错误" + err.Error())
|
||||
}
|
||||
|
||||
// 给Mac系统下发路由时,必须是标准的网络地址
|
||||
if strings.Split(ipMask, "/")[0] != ipNet.IP.String() {
|
||||
errMsg := fmt.Sprintf("RouteInclude 错误: 网络地址错误,建议: %s 改为 %s", v.Val, ipNet)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
|
||||
v.IpMask = ipMask
|
||||
routeInclude = append(routeInclude, v)
|
||||
}
|
||||
@@ -130,10 +137,16 @@ func SetGroup(g *Group) error {
|
||||
routeExclude := []ValData{}
|
||||
for _, v := range g.RouteExclude {
|
||||
if v.Val != "" {
|
||||
ipMask, _, err := parseIpNet(v.Val)
|
||||
ipMask, ipNet, err := parseIpNet(v.Val)
|
||||
if err != nil {
|
||||
return errors.New("RouteExclude 错误" + err.Error())
|
||||
}
|
||||
|
||||
if strings.Split(ipMask, "/")[0] != ipNet.IP.String() {
|
||||
errMsg := fmt.Sprintf("RouteInclude 错误: 网络地址错误,建议: %s 改为 %s", v.Val, ipNet)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
|
||||
v.IpMask = ipMask
|
||||
routeExclude = append(routeExclude, v)
|
||||
}
|
||||
|
Reference in New Issue
Block a user