package containers import ( "github.com/coroot/coroot-node-agent/common" "github.com/coroot/coroot-node-agent/utils" . "github.com/coroot/coroot-node-agent/utils/modelse" log "github.com/sirupsen/logrus" ) type WhiteListMap map[string][]WhiteSettingInfo func (r *Registry) getWhiteListByCodeType(codeType CodeType) []WhiteSettingInfo { return r.whiteListRules[codeType.WhiteCodeString()] } func (r *Registry) setWhiteList(whiteData WhiteData) { whiteListMap := make(WhiteListMap) for _, scop := range whiteData.Appscope { code := scop.Code for _, setting := range scop.Settings { whiteListMap[code] = append(whiteListMap[code], setting) } } r.whiteListRules = whiteListMap } func (r *Registry) getWhiteList() (bool, error) { if common.IsOpenFilter() { return false, nil } //hostId, _ := utils.GetHostID() //fmt.Println(hostId) whiteListReq := WhiteListReq{ HostId: 10154813500555812, AccountId: utils.GetAccountID(), } whiteData, err := r.connServer.WhiteList(whiteListReq) if err != nil { log.Errorf("report WhiteList info error is %v.", err) return false, err } //fmt.Println(r.whiteLastUpdatedTime) //fmt.Println(whiteData.LastUpdatedTime) // 不用更新 if r.whiteLastUpdatedTime >= 0 && r.whiteLastUpdatedTime == whiteData.LastUpdatedTime { return false, nil } // 更新时间 r.whiteLastUpdatedTime = whiteData.LastUpdatedTime r.setWhiteList(whiteData) return true, nil }