mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-09 02:20:18 +08:00
v0.0.3 - 更新security解析
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/oneclickvirt/basics/model"
|
||||
)
|
||||
|
||||
// chooseString 用于选择非空字符串
|
||||
func chooseString(src, dst string) string {
|
||||
if src != "" {
|
||||
@@ -14,7 +13,7 @@ func chooseString(src, dst string) string {
|
||||
return dst
|
||||
}
|
||||
|
||||
// CompareAndMergeIpInfo 用于比较和合并两个 IpInfo 结构体
|
||||
// CompareAndMergeIpInfo 用于比较和合并两个 IpInfo 结构体,非空则不替换
|
||||
func CompareAndMergeIpInfo(dst, src *model.IpInfo) (res *model.IpInfo, err error) {
|
||||
if src == nil {
|
||||
return nil, fmt.Errorf("Error merge IpInfo")
|
||||
@@ -31,7 +30,7 @@ func CompareAndMergeIpInfo(dst, src *model.IpInfo) (res *model.IpInfo, err error
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
// CompareAndMergeSecurityInfo 用于比较和合并两个 SecurityInfo 结构体
|
||||
// CompareAndMergeSecurityInfo 用于比较和合并两个 SecurityInfo 结构体,非空则不替换
|
||||
func CompareAndMergeSecurityInfo(dst, src *model.SecurityInfo) (res *model.SecurityInfo, err error) {
|
||||
if src == nil {
|
||||
return nil, fmt.Errorf("Error merge SecurityInfo")
|
||||
@@ -50,5 +49,6 @@ func CompareAndMergeSecurityInfo(dst, src *model.SecurityInfo) (res *model.Secur
|
||||
dst.IsVpn = chooseString(src.IsVpn, dst.IsVpn)
|
||||
dst.IsAnonymous = chooseString(src.IsAnonymous, dst.IsAnonymous)
|
||||
dst.IsThreat = chooseString(src.IsThreat, dst.IsThreat)
|
||||
dst.Tag = "D"
|
||||
return dst, nil
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/oneclickvirt/basics/model"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/basics/model"
|
||||
)
|
||||
|
||||
func ParseIpInfo(data map[string]interface{}) *model.IpInfo {
|
||||
@@ -41,37 +42,37 @@ func ParseSecurityInfo(data map[string]interface{}) *model.SecurityInfo {
|
||||
securityInfo := &model.SecurityInfo{}
|
||||
if security, ok := data["security"].(map[string]interface{}); ok {
|
||||
if isAbuser, ok := security["is_abuser"].(bool); ok {
|
||||
securityInfo.IsAbuser = strconv.FormatBool(isAbuser)
|
||||
securityInfo.IsAbuser = BoolToString(isAbuser)
|
||||
}
|
||||
if isAttacker, ok := security["is_attacker"].(bool); ok {
|
||||
securityInfo.IsAttacker = strconv.FormatBool(isAttacker)
|
||||
securityInfo.IsAttacker = BoolToString(isAttacker)
|
||||
}
|
||||
if isBogon, ok := security["is_bogon"].(bool); ok {
|
||||
securityInfo.IsBogon = strconv.FormatBool(isBogon)
|
||||
securityInfo.IsBogon = BoolToString(isBogon)
|
||||
}
|
||||
if isCloudProvider, ok := security["is_cloud_provider"].(bool); ok {
|
||||
securityInfo.IsCloudProvider = strconv.FormatBool(isCloudProvider)
|
||||
securityInfo.IsCloudProvider = BoolToString(isCloudProvider)
|
||||
}
|
||||
if isProxy, ok := security["is_proxy"].(bool); ok {
|
||||
securityInfo.IsProxy = strconv.FormatBool(isProxy)
|
||||
securityInfo.IsProxy = BoolToString(isProxy)
|
||||
}
|
||||
if isRelay, ok := security["is_relay"].(bool); ok {
|
||||
securityInfo.IsRelay = strconv.FormatBool(isRelay)
|
||||
securityInfo.IsRelay = BoolToString(isRelay)
|
||||
}
|
||||
if isTor, ok := security["is_tor"].(bool); ok {
|
||||
securityInfo.IsTor = strconv.FormatBool(isTor)
|
||||
securityInfo.IsTor = BoolToString(isTor)
|
||||
}
|
||||
if isTorExit, ok := security["is_tor_exit"].(bool); ok {
|
||||
securityInfo.IsTorExit = strconv.FormatBool(isTorExit)
|
||||
securityInfo.IsTorExit = BoolToString(isTorExit)
|
||||
}
|
||||
if isVpn, ok := security["is_vpn"].(bool); ok {
|
||||
securityInfo.IsVpn = strconv.FormatBool(isVpn)
|
||||
securityInfo.IsVpn = BoolToString(isVpn)
|
||||
}
|
||||
if isAnonymous, ok := security["is_anonymous"].(bool); ok {
|
||||
securityInfo.IsAnonymous = strconv.FormatBool(isAnonymous)
|
||||
securityInfo.IsAnonymous = BoolToString(isAnonymous)
|
||||
}
|
||||
if isThreat, ok := security["is_threat"].(bool); ok {
|
||||
securityInfo.IsThreat = strconv.FormatBool(isThreat)
|
||||
securityInfo.IsThreat = BoolToString(isThreat)
|
||||
}
|
||||
}
|
||||
return securityInfo
|
||||
|
Reference in New Issue
Block a user