Skip to content

Commit

Permalink
添加acl协议支持
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgyc committed Sep 4, 2024
1 parent 5b498cb commit 76779de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
3 changes: 3 additions & 0 deletions server/dbdata/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func SetGroup(g *Group) error {
v.IpProto = waterutil.UDP
case ICMP:
v.IpProto = waterutil.ICMP
default:
// 其他类型都是 all
v.Protocol = ALL
}

portsStr := v.Port
Expand Down
39 changes: 19 additions & 20 deletions server/handler/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,26 @@ func checkLinkAcl(group *dbdata.Group, pl *sessdata.Payload) bool {
}

for _, v := range group.LinkAcl {
// 循环判断ip和端口
if v.IpNet.Contains(ipDst) {

// 放行允许ip的ping
// if v.Ports == nil || len(v.Ports) == 0 {
// //单端口历史数据兼容
// port := uint16(v.Port.(float64))
// if port == ipPort || port == 0 || ipProto == waterutil.ICMP {
// if v.Action == dbdata.Allow {
// return true
// } else {
// return false
// }
// }
// } else {

// 先判断协议
// 兼容旧数据 v.Protocol == ""
if v.Protocol == "" || v.Protocol == dbdata.ALL || v.IpProto == ipProto {
// 放行允许ip的ping
// if v.Ports == nil || len(v.Ports) == 0 {
// //单端口历史数据兼容
// port := uint16(v.Port.(float64))
// if port == ipPort || port == 0 || ipProto == waterutil.ICMP {
// if v.Action == dbdata.Allow {
// return true
// } else {
// return false
// }
// }
// } else {

// 先判断协议
// 兼容旧数据 v.Protocol == ""
if v.Protocol == "" || v.Protocol == dbdata.ALL || v.IpProto == ipProto {
// 循环判断ip和端口
if v.IpNet.Contains(ipDst) {
// icmp 不判断端口
if ipProto == waterutil.ICMP {
// icmp 不判断端口
if v.Action == dbdata.Allow {
return true
} else {
Expand Down

0 comments on commit 76779de

Please sign in to comment.