2020-11-09 10:45:44 +08:00
|
|
|
|
package iplibrary
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
2024-04-06 15:37:14 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
|
2022-10-26 10:42:16 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
2020-11-09 10:45:44 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
2022-09-21 16:49:48 +08:00
|
|
|
|
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
|
2020-11-09 10:45:44 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/events"
|
2021-12-08 15:17:45 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/goman"
|
2020-12-17 17:36:10 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
2020-11-09 10:45:44 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/rpc"
|
2024-03-31 10:08:53 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/trackers"
|
2024-04-17 13:10:55 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/utils/idles"
|
2021-11-05 14:58:10 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf"
|
2021-12-09 12:07:46 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/zero"
|
2020-11-09 10:45:44 +08:00
|
|
|
|
"github.com/iwind/TeaGo/Tea"
|
2024-03-31 10:08:53 +08:00
|
|
|
|
"github.com/iwind/TeaGo/types"
|
|
|
|
|
|
"os"
|
2020-11-09 10:45:44 +08:00
|
|
|
|
"sync"
|
|
|
|
|
|
"time"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var SharedIPListManager = NewIPListManager()
|
2020-11-10 09:22:17 +08:00
|
|
|
|
var IPListUpdateNotify = make(chan bool, 1)
|
2020-11-09 10:45:44 +08:00
|
|
|
|
|
|
|
|
|
|
func init() {
|
2023-03-10 15:14:14 +08:00
|
|
|
|
if !teaconst.IsMain {
|
2022-09-21 16:49:48 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-16 15:58:10 +08:00
|
|
|
|
events.On(events.EventLoaded, func() {
|
2021-12-08 15:17:45 +08:00
|
|
|
|
goman.New(func() {
|
|
|
|
|
|
SharedIPListManager.Start()
|
|
|
|
|
|
})
|
2020-11-09 10:45:44 +08:00
|
|
|
|
})
|
2023-06-23 17:45:39 +08:00
|
|
|
|
events.OnClose(func() {
|
2022-01-12 20:31:04 +08:00
|
|
|
|
SharedIPListManager.Stop()
|
|
|
|
|
|
})
|
2022-09-21 16:49:48 +08:00
|
|
|
|
|
|
|
|
|
|
var ticker = time.NewTicker(24 * time.Hour)
|
|
|
|
|
|
goman.New(func() {
|
2024-04-17 13:10:55 +08:00
|
|
|
|
idles.RunTicker(ticker, func() {
|
2022-09-21 16:49:48 +08:00
|
|
|
|
SharedIPListManager.DeleteExpiredItems()
|
2024-04-17 13:10:55 +08:00
|
|
|
|
})
|
2022-09-21 16:49:48 +08:00
|
|
|
|
})
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-16 15:58:10 +08:00
|
|
|
|
// IPListManager IP名单管理
|
2020-11-09 10:45:44 +08:00
|
|
|
|
type IPListManager struct {
|
2022-01-12 20:31:04 +08:00
|
|
|
|
ticker *time.Ticker
|
|
|
|
|
|
|
2024-03-31 10:08:53 +08:00
|
|
|
|
db IPListDB
|
2020-11-09 10:45:44 +08:00
|
|
|
|
|
2023-04-19 12:01:02 +08:00
|
|
|
|
lastVersion int64
|
|
|
|
|
|
fetchPageSize int64
|
2020-11-09 10:45:44 +08:00
|
|
|
|
|
|
|
|
|
|
listMap map[int64]*IPList
|
2024-04-17 13:10:55 +08:00
|
|
|
|
mu sync.RWMutex
|
2023-04-19 12:01:02 +08:00
|
|
|
|
|
|
|
|
|
|
isFirstTime bool
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewIPListManager() *IPListManager {
|
|
|
|
|
|
return &IPListManager{
|
2023-04-19 12:01:02 +08:00
|
|
|
|
fetchPageSize: 5_000,
|
|
|
|
|
|
listMap: map[int64]*IPList{},
|
|
|
|
|
|
isFirstTime: true,
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (this *IPListManager) Start() {
|
2024-04-06 10:07:39 +08:00
|
|
|
|
this.Init()
|
2021-11-14 20:34:04 +08:00
|
|
|
|
|
2020-11-09 10:45:44 +08:00
|
|
|
|
// 第一次读取
|
2024-04-06 10:07:39 +08:00
|
|
|
|
err := this.Loop()
|
2020-11-09 10:45:44 +08:00
|
|
|
|
if err != nil {
|
2021-11-10 21:51:56 +08:00
|
|
|
|
remotelogs.ErrorObject("IP_LIST_MANAGER", err)
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 20:31:04 +08:00
|
|
|
|
this.ticker = time.NewTicker(60 * time.Second)
|
2021-11-17 16:16:09 +08:00
|
|
|
|
if Tea.IsTesting() {
|
2022-01-12 20:31:04 +08:00
|
|
|
|
this.ticker = time.NewTicker(10 * time.Second)
|
2021-11-17 16:16:09 +08:00
|
|
|
|
}
|
2022-03-06 19:40:26 +08:00
|
|
|
|
var countErrors = 0
|
2020-11-10 09:22:17 +08:00
|
|
|
|
for {
|
|
|
|
|
|
select {
|
2022-01-12 20:31:04 +08:00
|
|
|
|
case <-this.ticker.C:
|
2020-11-10 09:22:17 +08:00
|
|
|
|
case <-IPListUpdateNotify:
|
|
|
|
|
|
}
|
2024-04-06 10:07:39 +08:00
|
|
|
|
err = this.Loop()
|
2020-11-09 10:45:44 +08:00
|
|
|
|
if err != nil {
|
2020-11-15 11:58:08 +08:00
|
|
|
|
countErrors++
|
2020-11-10 09:22:17 +08:00
|
|
|
|
|
2021-11-10 21:51:56 +08:00
|
|
|
|
remotelogs.ErrorObject("IP_LIST_MANAGER", err)
|
2020-11-10 09:22:17 +08:00
|
|
|
|
|
2020-11-15 11:58:08 +08:00
|
|
|
|
// 连续错误小于3次的我们立即重试
|
|
|
|
|
|
if countErrors <= 3 {
|
|
|
|
|
|
select {
|
|
|
|
|
|
case IPListUpdateNotify <- true:
|
|
|
|
|
|
default:
|
|
|
|
|
|
}
|
2020-11-10 09:22:17 +08:00
|
|
|
|
}
|
2020-11-15 11:58:08 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
countErrors = 0
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 20:31:04 +08:00
|
|
|
|
func (this *IPListManager) Stop() {
|
|
|
|
|
|
if this.ticker != nil {
|
|
|
|
|
|
this.ticker.Stop()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-06 10:07:39 +08:00
|
|
|
|
func (this *IPListManager) Init() {
|
2021-11-17 16:16:09 +08:00
|
|
|
|
// 从数据库中当中读取数据
|
2024-03-31 10:08:53 +08:00
|
|
|
|
// 检查sqlite文件是否存在,以便决定使用sqlite还是kv
|
|
|
|
|
|
var sqlitePath = Tea.Root + "/data/ip_list.db"
|
|
|
|
|
|
_, sqliteErr := os.Stat(sqlitePath)
|
|
|
|
|
|
|
|
|
|
|
|
var db IPListDB
|
|
|
|
|
|
var err error
|
2024-04-02 19:54:04 +08:00
|
|
|
|
if sqliteErr == nil || !teaconst.EnableKVCacheStore {
|
2024-03-31 12:54:30 +08:00
|
|
|
|
db, err = NewSQLiteIPList()
|
2024-03-31 10:08:53 +08:00
|
|
|
|
} else {
|
2024-03-31 12:54:30 +08:00
|
|
|
|
db, err = NewKVIPList()
|
2024-03-31 10:08:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-17 16:16:09 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
|
remotelogs.Error("IP_LIST_MANAGER", "create ip list local database failed: "+err.Error())
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.db = db
|
|
|
|
|
|
|
2022-03-06 19:40:26 +08:00
|
|
|
|
// 删除本地数据库中过期的条目
|
|
|
|
|
|
_ = db.DeleteExpiredItems()
|
|
|
|
|
|
|
|
|
|
|
|
// 本地数据库中最大版本号
|
2024-03-31 10:08:53 +08:00
|
|
|
|
this.lastVersion, err = db.ReadMaxVersion()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
remotelogs.Error("IP_LIST_MANAGER", "find max version failed: "+err.Error())
|
|
|
|
|
|
this.lastVersion = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
remotelogs.Println("IP_LIST_MANAGER", "starting from '"+db.Name()+"' version '"+types.String(this.lastVersion)+"' ...")
|
2022-03-06 19:40:26 +08:00
|
|
|
|
|
|
|
|
|
|
// 从本地数据库中加载
|
2021-11-17 16:16:09 +08:00
|
|
|
|
var offset int64 = 0
|
2023-04-19 12:01:02 +08:00
|
|
|
|
var size int64 = 2_000
|
2024-03-31 10:08:53 +08:00
|
|
|
|
|
|
|
|
|
|
var tr = trackers.Begin("IP_LIST_MANAGER:load")
|
|
|
|
|
|
defer tr.End()
|
|
|
|
|
|
|
2021-11-17 16:16:09 +08:00
|
|
|
|
for {
|
2024-03-31 10:08:53 +08:00
|
|
|
|
items, goNext, readErr := db.ReadItems(offset, size)
|
2022-08-30 18:49:21 +08:00
|
|
|
|
var l = len(items)
|
2024-03-31 10:08:53 +08:00
|
|
|
|
if readErr != nil {
|
|
|
|
|
|
remotelogs.Error("IP_LIST_MANAGER", "read ip list from local database failed: "+readErr.Error())
|
2021-11-17 16:16:09 +08:00
|
|
|
|
} else {
|
2024-04-21 10:33:12 +08:00
|
|
|
|
this.processItems(items, false)
|
2024-03-31 10:08:53 +08:00
|
|
|
|
if !goNext {
|
2021-11-17 16:16:09 +08:00
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-30 18:49:21 +08:00
|
|
|
|
offset += int64(l)
|
2021-11-17 16:16:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-06 10:07:39 +08:00
|
|
|
|
func (this *IPListManager) Loop() error {
|
2022-10-26 10:42:16 +08:00
|
|
|
|
// 是否同步IP名单
|
|
|
|
|
|
nodeConfig, _ := nodeconfigs.SharedNodeConfig()
|
|
|
|
|
|
if nodeConfig != nil && !nodeConfig.EnableIPLists {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-19 12:01:02 +08:00
|
|
|
|
// 第一次同步则打印信息
|
|
|
|
|
|
if this.isFirstTime {
|
|
|
|
|
|
remotelogs.Println("IP_LIST_MANAGER", "initializing ip items ...")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-09 10:45:44 +08:00
|
|
|
|
for {
|
|
|
|
|
|
hasNext, err := this.fetch()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return err
|
|
|
|
|
|
}
|
|
|
|
|
|
if !hasNext {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-11-14 20:34:04 +08:00
|
|
|
|
time.Sleep(1 * time.Second)
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-19 12:01:02 +08:00
|
|
|
|
// 第一次同步则打印信息
|
|
|
|
|
|
if this.isFirstTime {
|
|
|
|
|
|
this.isFirstTime = false
|
|
|
|
|
|
remotelogs.Println("IP_LIST_MANAGER", "finished initializing ip items")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-09 10:45:44 +08:00
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (this *IPListManager) fetch() (hasNext bool, err error) {
|
|
|
|
|
|
rpcClient, err := rpc.SharedRPC()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return false, err
|
|
|
|
|
|
}
|
2022-08-24 20:04:46 +08:00
|
|
|
|
itemsResp, err := rpcClient.IPItemRPC.ListIPItemsAfterVersion(rpcClient.Context(), &pb.ListIPItemsAfterVersionRequest{
|
2023-04-19 12:01:02 +08:00
|
|
|
|
Version: this.lastVersion,
|
|
|
|
|
|
Size: this.fetchPageSize,
|
2020-11-09 10:45:44 +08:00
|
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
2022-04-08 15:25:53 +08:00
|
|
|
|
if rpc.IsConnError(err) {
|
2023-08-13 14:25:59 +08:00
|
|
|
|
remotelogs.Debug("IP_LIST_MANAGER", "rpc connection error: "+err.Error())
|
2022-04-08 15:25:53 +08:00
|
|
|
|
return false, nil
|
|
|
|
|
|
}
|
2020-11-09 10:45:44 +08:00
|
|
|
|
return false, err
|
|
|
|
|
|
}
|
2024-05-05 19:10:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 更新版本号
|
|
|
|
|
|
defer func() {
|
|
|
|
|
|
if itemsResp.Version > this.lastVersion {
|
|
|
|
|
|
this.lastVersion = itemsResp.Version
|
|
|
|
|
|
err = this.db.UpdateMaxVersion(itemsResp.Version)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
remotelogs.Error("IP_LIST_MANAGER", "update max version to database: "+err.Error())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
2022-08-30 18:49:21 +08:00
|
|
|
|
var items = itemsResp.IpItems
|
2020-11-09 10:45:44 +08:00
|
|
|
|
if len(items) == 0 {
|
|
|
|
|
|
return false, nil
|
|
|
|
|
|
}
|
2021-11-17 16:16:09 +08:00
|
|
|
|
|
|
|
|
|
|
// 保存到本地数据库
|
|
|
|
|
|
if this.db != nil {
|
|
|
|
|
|
for _, item := range items {
|
|
|
|
|
|
err = this.db.AddItem(item)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
remotelogs.Error("IP_LIST_MANAGER", "insert item to local database failed: "+err.Error())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.processItems(items, true)
|
|
|
|
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (this *IPListManager) FindList(listId int64) *IPList {
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.RLock()
|
2023-08-08 15:39:00 +08:00
|
|
|
|
var list = this.listMap[listId]
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.RUnlock()
|
|
|
|
|
|
|
2021-11-17 16:16:09 +08:00
|
|
|
|
return list
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 16:49:48 +08:00
|
|
|
|
func (this *IPListManager) DeleteExpiredItems() {
|
|
|
|
|
|
if this.db != nil {
|
|
|
|
|
|
_ = this.db.DeleteExpiredItems()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-06 10:07:39 +08:00
|
|
|
|
func (this *IPListManager) ListMap() map[int64]*IPList {
|
|
|
|
|
|
return this.listMap
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-19 12:01:02 +08:00
|
|
|
|
// 处理IP条目
|
2022-03-06 19:40:26 +08:00
|
|
|
|
func (this *IPListManager) processItems(items []*pb.IPItem, fromRemote bool) {
|
2021-12-09 12:07:46 +08:00
|
|
|
|
var changedLists = map[*IPList]zero.Zero{}
|
2020-11-09 10:45:44 +08:00
|
|
|
|
for _, item := range items {
|
2023-09-12 16:05:18 +08:00
|
|
|
|
// 调试
|
|
|
|
|
|
if Tea.IsTesting() {
|
|
|
|
|
|
this.debugItem(item)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-17 16:16:09 +08:00
|
|
|
|
var list *IPList
|
|
|
|
|
|
// TODO 实现节点专有List
|
|
|
|
|
|
if item.ServerId > 0 { // 服务专有List
|
|
|
|
|
|
switch item.ListType {
|
|
|
|
|
|
case "black":
|
|
|
|
|
|
list = SharedServerListManager.FindBlackList(item.ServerId, true)
|
|
|
|
|
|
case "white":
|
|
|
|
|
|
list = SharedServerListManager.FindWhiteList(item.ServerId, true)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if item.IsGlobal { // 全局List
|
|
|
|
|
|
switch item.ListType {
|
|
|
|
|
|
case "black":
|
|
|
|
|
|
list = GlobalBlackIPList
|
|
|
|
|
|
case "white":
|
|
|
|
|
|
list = GlobalWhiteIPList
|
|
|
|
|
|
}
|
|
|
|
|
|
} else { // 其他List
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.Lock()
|
2021-11-17 16:16:09 +08:00
|
|
|
|
list = this.listMap[item.ListId]
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.Unlock()
|
2021-11-17 16:16:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
if list == nil {
|
2020-11-09 10:45:44 +08:00
|
|
|
|
list = NewIPList()
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.Lock()
|
2020-11-09 10:45:44 +08:00
|
|
|
|
this.listMap[item.ListId] = list
|
2024-04-06 15:37:14 +08:00
|
|
|
|
this.mu.Unlock()
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
2021-10-04 17:42:38 +08:00
|
|
|
|
|
2021-12-09 12:07:46 +08:00
|
|
|
|
changedLists[list] = zero.New()
|
2021-10-04 17:42:38 +08:00
|
|
|
|
|
2020-11-09 10:45:44 +08:00
|
|
|
|
if item.IsDeleted {
|
2022-04-09 18:28:22 +08:00
|
|
|
|
list.Delete(uint64(item.Id))
|
2021-02-06 17:34:33 +08:00
|
|
|
|
|
2021-11-17 16:16:09 +08:00
|
|
|
|
// 从WAF名单中删除
|
2022-03-06 19:40:26 +08:00
|
|
|
|
waf.SharedIPBlackList.RemoveIP(item.IpFrom, item.ServerId, fromRemote)
|
2021-11-05 14:58:10 +08:00
|
|
|
|
|
2021-02-06 17:34:33 +08:00
|
|
|
|
// 操作事件
|
2022-03-06 19:40:26 +08:00
|
|
|
|
if fromRemote {
|
2021-11-17 16:16:09 +08:00
|
|
|
|
SharedActionManager.DeleteItem(item.ListType, item)
|
|
|
|
|
|
}
|
2021-02-06 17:34:33 +08:00
|
|
|
|
|
2020-11-09 10:45:44 +08:00
|
|
|
|
continue
|
|
|
|
|
|
}
|
2021-02-06 17:34:33 +08:00
|
|
|
|
|
2021-10-04 17:42:38 +08:00
|
|
|
|
list.AddDelay(&IPItem{
|
2022-04-09 18:28:22 +08:00
|
|
|
|
Id: uint64(item.Id),
|
2021-02-06 17:34:33 +08:00
|
|
|
|
Type: item.Type,
|
2024-04-06 15:37:14 +08:00
|
|
|
|
IPFrom: iputils.ToBytes(item.IpFrom),
|
|
|
|
|
|
IPTo: iputils.ToBytes(item.IpTo),
|
2021-02-06 17:34:33 +08:00
|
|
|
|
ExpiredAt: item.ExpiredAt,
|
|
|
|
|
|
EventLevel: item.EventLevel,
|
2020-11-09 10:45:44 +08:00
|
|
|
|
})
|
2021-02-06 17:34:33 +08:00
|
|
|
|
|
|
|
|
|
|
// 事件操作
|
2022-03-06 19:40:26 +08:00
|
|
|
|
if fromRemote {
|
2021-11-17 16:16:09 +08:00
|
|
|
|
SharedActionManager.DeleteItem(item.ListType, item)
|
|
|
|
|
|
SharedActionManager.AddItem(item.ListType, item)
|
|
|
|
|
|
}
|
2020-11-09 10:45:44 +08:00
|
|
|
|
}
|
2021-10-04 17:42:38 +08:00
|
|
|
|
|
2024-03-30 14:42:56 +08:00
|
|
|
|
if len(changedLists) > 0 {
|
|
|
|
|
|
for changedList := range changedLists {
|
|
|
|
|
|
changedList.Sort()
|
|
|
|
|
|
}
|
2021-10-04 17:42:38 +08:00
|
|
|
|
}
|
2021-11-14 20:34:04 +08:00
|
|
|
|
}
|
2023-09-12 16:05:18 +08:00
|
|
|
|
|
|
|
|
|
|
// 调试IP信息
|
|
|
|
|
|
func (this *IPListManager) debugItem(item *pb.IPItem) {
|
2024-03-31 10:08:53 +08:00
|
|
|
|
var ipRange = item.IpFrom
|
|
|
|
|
|
if len(item.IpTo) > 0 {
|
|
|
|
|
|
ipRange += " - " + item.IpTo
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-12 16:05:18 +08:00
|
|
|
|
if item.IsDeleted {
|
2024-03-31 10:08:53 +08:00
|
|
|
|
remotelogs.Debug("IP_ITEM_DEBUG", "delete '"+ipRange+"'")
|
2023-09-12 16:05:18 +08:00
|
|
|
|
} else {
|
2024-03-31 10:08:53 +08:00
|
|
|
|
remotelogs.Debug("IP_ITEM_DEBUG", "add '"+ipRange+"'")
|
2023-09-12 16:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|