featuredb

package
v0.9.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func FarSmaller

func FarSmaller(a, b int) bool

判断a是否比b的1/3还要小

func Init

func Init(path string, size int) error

func IsSimilar

func IsSimilar(a, b int) bool

判断两个整数是否大致相等

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func (*DB) IPToKey

func (d *DB) IPToKey(ip string) int64

ip转换为key TODO 需要考虑ip比较多,因此需要缩减key的长度

func (*DB) Record

func (d *DB) Record()

func (*DB) Stat

func (d *DB) Stat(pName, mName string) *StatWrapper

func (*DB) VarsToKey

func (d *DB) VarsToKey(vars map[string]string) int64

type IPStat

type IPStat struct {
	Vars map[int64]int64 //针对某个变量的访问时间戳
}

热点IP统计信息

func (*IPStat) IsStealingIP

func (ip *IPStat) IsStealingIP(predictedType UrlType) bool

type IPStatPool

type IPStatPool map[int64]*IPStat

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"`
	SizeOfIPs     map[int64]bool     `` /* 161-byte string literal not displayed */
	StatPerVars   map[int64]*VarStat `` /* 164-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Stat) Descriptor deprecated

func (*Stat) Descriptor() ([]byte, []int)

Deprecated: Use Stat.ProtoReflect.Descriptor instead.

func (*Stat) GetPredictedType

func (x *Stat) GetPredictedType() UrlType

func (*Stat) GetSizeOfIPs

func (x *Stat) GetSizeOfIPs() map[int64]bool

func (*Stat) GetStatPerVars

func (x *Stat) GetStatPerVars() map[int64]*VarStat

func (*Stat) ProtoMessage

func (*Stat) ProtoMessage()

func (*Stat) ProtoReflect

func (x *Stat) ProtoReflect() protoreflect.Message

func (*Stat) Reset

func (x *Stat) Reset()

func (*Stat) String

func (x *Stat) String() string

type StatInDb

type StatInDb interface {
	JudgeRequest(ip string, parsInPath map[string]string) Judgement
}

func GetStatForAPI

func GetStatForAPI(path, mName string, def *openapi3.Operation) StatInDb

GetStatForAPI 根据定义从统计库中获得相关统计

type StatWrapper

type StatWrapper struct {
	// contains filtered or unexported fields
}

func (*StatWrapper) JudgeRequest

func (d *StatWrapper) JudgeRequest(ip string, vars map[string]string) Judgement

func (*StatWrapper) Save

func (d *StatWrapper) Save() error

type UrlType

type UrlType int32

定义URL对应的数据接口的业务逻辑类型

const (
	//探测URL和客户IP无聚类关系,推断为通用性数据接口,应注意该接口下是否有用户敏感数据,如涉及手机等信息的用户名等
	UrlType_UrlUnspecified      UrlType = 0
	UrlType_UrlNormal           UrlType = 1
	UrlType_UrlRestricted       UrlType = 2
	UrlType_UrlForSpecifiedUser UrlType = 3 //TODO 配合proxy对返回进行进一步探测
)

func (UrlType) Descriptor

func (UrlType) Descriptor() protoreflect.EnumDescriptor

func (UrlType) Enum

func (x UrlType) Enum() *UrlType

func (UrlType) EnumDescriptor deprecated

func (UrlType) EnumDescriptor() ([]byte, []int)

Deprecated: Use UrlType.Descriptor instead.

func (UrlType) Number

func (x UrlType) Number() protoreflect.EnumNumber

func (UrlType) String

func (x UrlType) String() string

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"`
	StatPerIPs    map[int64]int64 `` /* 163-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*VarStat) Descriptor deprecated

func (*VarStat) Descriptor() ([]byte, []int)

Deprecated: Use VarStat.ProtoReflect.Descriptor instead.

func (*VarStat) GetPredictedType

func (x *VarStat) GetPredictedType() UrlType

func (*VarStat) GetStatPerIPs

func (x *VarStat) GetStatPerIPs() map[int64]int64

func (*VarStat) ProtoMessage

func (*VarStat) ProtoMessage()

func (*VarStat) ProtoReflect

func (x *VarStat) ProtoReflect() protoreflect.Message

func (*VarStat) Reset

func (x *VarStat) Reset()

func (*VarStat) String

func (x *VarStat) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL