Documentation ¶
Index ¶
- Constants
- Variables
- func FarSmaller(a, b int) bool
- func Init(path string, size int) error
- func InitByDb(db *bolt.DB, size int)
- func IsSimilar(a, b int) bool
- type DB
- type GlocalIpStat
- type IPStatPool
- type IpStatForOp
- func (*IpStatForOp) Descriptor() ([]byte, []int)deprecated
- func (ip *IpStatForOp) GetFingerprint() int64
- func (x *IpStatForOp) GetStatPerVars() map[int64]int64
- func (*IpStatForOp) ProtoMessage()
- func (x *IpStatForOp) ProtoReflect() protoreflect.Message
- func (x *IpStatForOp) Reset()
- func (x *IpStatForOp) String() string
- type JudgeLevel
- type Judgement
- type Stat
- func (*Stat) Descriptor() ([]byte, []int)deprecated
- func (x *Stat) GetPredictedType() UrlType
- func (x *Stat) GetSizeOfIPs() map[int64]int64
- func (x *Stat) GetStatOfSingleIP() map[int64]*IpStatForOp
- func (x *Stat) GetStatPerVars() map[int64]*VarStat
- func (*Stat) ProtoMessage()
- func (x *Stat) ProtoReflect() protoreflect.Message
- func (x *Stat) Reset()
- func (x *Stat) String() string
- type StatInDb
- type StatWrapper
- type UrlType
- type VarStat
Constants ¶
View Source
const FingerPrintUnit = 50
View Source
const IntervalBetweenSlowRequest = 3000
Variables ¶
View Source
var ( Prefix_Url byte = 1 //SOH Prefix_Method byte = 2 //STX FeatureDBStatTable = []byte("_apicat_FeatureDBStatTable") )
View Source
var ( UrlType_name = map[int32]string{ 0: "UrlUnspecified", 1: "UrlNormal", 2: "UrlRestricted", 3: "UrlForSpecifiedUser", } UrlType_value = map[string]int32{ "UrlUnspecified": 0, "UrlNormal": 1, "UrlRestricted": 2, "UrlForSpecifiedUser": 3, } )
Enum value maps for UrlType.
View Source
var File_featuredb_stat_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Stat ¶
func (d *DB) Stat(pName, mName string) *StatWrapper
type GlocalIpStat ¶
type GlocalIpStat struct { IpMap map[int64]*Stat `` /* 152-byte string literal not displayed */ // contains filtered or unexported fields }
func (*GlocalIpStat) Descriptor
deprecated
func (*GlocalIpStat) Descriptor() ([]byte, []int)
Deprecated: Use GlocalIpStat.ProtoReflect.Descriptor instead.
func (*GlocalIpStat) GetIpMap ¶
func (x *GlocalIpStat) GetIpMap() map[int64]*Stat
func (*GlocalIpStat) ProtoMessage ¶
func (*GlocalIpStat) ProtoMessage()
func (*GlocalIpStat) ProtoReflect ¶
func (x *GlocalIpStat) ProtoReflect() protoreflect.Message
func (*GlocalIpStat) Reset ¶
func (x *GlocalIpStat) Reset()
func (*GlocalIpStat) String ¶
func (x *GlocalIpStat) String() string
type IPStatPool ¶
type IpStatForOp ¶
type IpStatForOp struct { StatPerVars map[int64]int64 `` /* 165-byte string literal not displayed */ // contains filtered or unexported fields }
func (*IpStatForOp) Descriptor
deprecated
func (*IpStatForOp) Descriptor() ([]byte, []int)
Deprecated: Use IpStatForOp.ProtoReflect.Descriptor instead.
func (*IpStatForOp) GetStatPerVars ¶
func (x *IpStatForOp) GetStatPerVars() map[int64]int64
func (*IpStatForOp) ProtoMessage ¶
func (*IpStatForOp) ProtoMessage()
func (*IpStatForOp) ProtoReflect ¶
func (x *IpStatForOp) ProtoReflect() protoreflect.Message
func (*IpStatForOp) Reset ¶
func (x *IpStatForOp) Reset()
func (*IpStatForOp) String ¶
func (x *IpStatForOp) String() string
type JudgeLevel ¶
type JudgeLevel byte
判断级别,因为特性库对于访问行为的判断基于现有访问判定模型进行 因此,每次访问都对错误有一个可能性的判定,可能性越高说明本次访问为错误访问的可能性越大 max 100
func (JudgeLevel) String ¶
func (j JudgeLevel) String() string
type Judgement ¶
type Judgement interface {
GetErrorType() etype.EntryError
}
type Stat ¶
type Stat struct { PredictedType UrlType `protobuf:"varint,1,opt,name=PredictedType,proto3,enum=featuredb.UrlType" json:"PredictedType,omitempty"` //并发访问量指纹,50为一段,每段记录一个指纹 SizeOfIPs map[int64]int64 `` /* 161-byte string literal not displayed */ //统计每个参数的ip分布情况,用于和总的ip分布进行对比,获得该url对应的业务逻辑类型 StatPerVars map[int64]*VarStat `` /* 164-byte string literal not displayed */ //统计每个IP的参数分布情况,用于生成该IP的参数指纹 StatOfSingleIP map[int64]*IpStatForOp `` /* 170-byte string literal not displayed */ // contains filtered or unexported fields }
一个path-method一个的统计信息
func (*Stat) Descriptor
deprecated
func (*Stat) GetPredictedType ¶
func (*Stat) GetSizeOfIPs ¶
func (*Stat) GetStatOfSingleIP ¶
func (x *Stat) GetStatOfSingleIP() map[int64]*IpStatForOp
func (*Stat) GetStatPerVars ¶
func (*Stat) ProtoMessage ¶
func (*Stat) ProtoMessage()
func (*Stat) ProtoReflect ¶
func (x *Stat) ProtoReflect() protoreflect.Message
type StatInDb ¶
type StatWrapper ¶
type StatWrapper struct {
// contains filtered or unexported fields
}
每个path-method一个统计信息
func (*StatWrapper) IsStealingIP ¶
func (d *StatWrapper) IsStealingIP(fp int64) bool
判断是否是盗用IP,判断目前这个指纹
func (*StatWrapper) JudgeRequest ¶
func (*StatWrapper) Save ¶
func (d *StatWrapper) Save() error
type UrlType ¶
type UrlType int32
定义URL对应的数据接口的业务逻辑类型
func (UrlType) Descriptor ¶
func (UrlType) Descriptor() protoreflect.EnumDescriptor
func (UrlType) EnumDescriptor
deprecated
func (UrlType) Number ¶
func (x UrlType) Number() protoreflect.EnumNumber
func (UrlType) Type ¶
func (UrlType) Type() protoreflect.EnumType
type VarStat ¶
type VarStat struct { //参数只可能是限制型或者通用型或未判定 //限制型参数对应url的限制型和用户型 PredictedType UrlType `protobuf:"varint,1,opt,name=PredictedType,proto3,enum=featuredb.UrlType" json:"PredictedType,omitempty"` //用于统计ip和参数值的关系,判定URL类型的参数 StatPerIPs map[int64]int64 `` /* 163-byte string literal not displayed */ // contains filtered or unexported fields }
func (*VarStat) Descriptor
deprecated
func (*VarStat) GetPredictedType ¶
func (*VarStat) GetStatPerIPs ¶
func (*VarStat) ProtoMessage ¶
func (*VarStat) ProtoMessage()
func (*VarStat) ProtoReflect ¶
func (x *VarStat) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.