object

package
v0.0.0-...-17edfda Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Refer to https://github.com/EagleChen/mapmutex

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCaptor

func AddCaptor(captor *Captor) bool

func AddFaker

func AddFaker(faker *Faker) bool

func AddImpression

func AddImpression(id string, sessionId string, websiteId string, userId string, trace *Trace) bool

func AddImpressions

func AddImpressions(impressions []*Impression) bool

func AddImpressionsSafe

func AddImpressionsSafe(impressions []*Impression) bool

func AddPage

func AddPage(page *Page) bool

func AddSession

func AddSession(id string, websiteId string, userAgent string, clientIp string, userId string) bool

func AddSessions

func AddSessions(sessions []*Session) bool

func AddSessionsSafe

func AddSessionsSafe(sessions []*Session) bool

func AddWebsite

func AddWebsite(website *Website) bool

func AppendTraceToImpression

func AppendTraceToImpression(id string, websiteId string, trace *Trace)

func DeleteCaptor

func DeleteCaptor(captor *Captor) bool

func DeleteFaker

func DeleteFaker(faker *Faker) bool

func DeleteImpression

func DeleteImpression(id string) bool

func DeleteImpressions

func DeleteImpressions(websiteId string) bool

func DeletePage

func DeletePage(id string) bool

func DeleteSession

func DeleteSession(id string, websiteId string) bool

func DeleteSessions

func DeleteSessions(websiteId string) bool

func DeleteWebsite

func DeleteWebsite(id string) bool

func InitMapMutexes

func InitMapMutexes()

func InitOrmManager

func InitOrmManager()

func UpdateCaptor

func UpdateCaptor(id string, captor *Captor) bool

func UpdateFaker

func UpdateFaker(id string, faker *Faker) bool

func UpdatePage

func UpdatePage(id string, page *Page) bool

func UpdateWebsite

func UpdateWebsite(id string, website *Website) bool

Types

type Captor

type Captor struct {
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	Title  string `xorm:"varchar(100)" json:"title"`
	Script string `xorm:"mediumtext" json:"script"`
}

func GetCaptor

func GetCaptor(id string) *Captor

func GetCaptors

func GetCaptors() []*Captor

type Event

type Event struct {
	Id        int     `json:"id"`
	Timestamp float64 `json:"timestamp"`
	Type      string  `json:"type"`
	Button    string  `json:"button"`
	X         int     `json:"x"`
	Y         int     `json:"y"`
	DeltaX    int     `json:"deltaX"`
	DeltaY    int     `json:"deltaY"`
	Width     int     `json:"width"`
	Height    int     `json:"height"`

	Speed        int `json:"speed"`
	Acceleration int `json:"acceleration"`
}

type Faker

type Faker struct {
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	Title  string `xorm:"varchar(100)" json:"title"`
	Script string `xorm:"mediumtext" json:"script"`
}

func GetFaker

func GetFaker(id string) *Faker

func GetFakers

func GetFakers() []*Faker

type Impression

type Impression struct {
	Id          string `xorm:"varchar(100) notnull pk" json:"id"`
	SessionId   string `xorm:"varchar(100)" json:"sessionId"`
	WebsiteId   string `xorm:"varchar(100) notnull pk" json:"websiteId"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UrlPath     string `xorm:"varchar(500)" json:"urlPath"`

	Width        int    `json:"width"`
	Height       int    `json:"height"`
	PageLoadTime string `xorm:"varchar(100)" json:"pageLoadTime"`

	UserAgent string `xorm:"varchar(500)" json:"userAgent"`
	ClientIp  string `xorm:"varchar(100)" json:"clientIp"`
	UserId    string `xorm:"varchar(100)" json:"userId"`

	Label     int    `json:"label"`
	Guess     int    `json:"guess"`
	Reason    string `json:"reason"`
	RuleId    int    `json:"ruleId"`
	RuleStart int    `json:"ruleStart"`
	RuleEnd   int    `json:"ruleEnd"`

	Events []*Event `xorm:"mediumtext" json:"events"`
}

func GetImpression

func GetImpression(id string, websiteId string) *Impression

func GetImpressions

func GetImpressions(websiteId string, sessionId string, sortField string, sortOrder string) []*Impression

func GetImpressionsAll

func GetImpressionsAll(websiteId string, sortField string, sortOrder string) []*Impression

type MapMutex

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

Mutex is the mutex with synchronized map it's for reducing unnecessary locks among different keys

func NewMapMutex

func NewMapMutex() *MapMutex

NewMapMutex returns a mapmutex with default configs

func (*MapMutex) TryLock

func (m *MapMutex) TryLock(key string) (gotLock bool)

TryLock tries to aquire the lock.

func (*MapMutex) Unlock

func (m *MapMutex) Unlock(key string)

Unlock unlocks for the key please call Unlock only after having aquired the lock

type OrmManager

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

OrmManager represents the MySQL ormManager for policy storage.

func NewOrmManager

func NewOrmManager(driverName string, dataSourceName string) *OrmManager

NewOrmManager is the constructor for OrmManager.

type Page

type Page struct {
	Id          string `xorm:"varchar(100) notnull pk" json:"id"`
	WebsiteId   string `xorm:"varchar(100)" json:"websiteId"`
	UrlPath     string `xorm:"varchar(500)" json:"urlPath"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	Width         int    `json:"width"`
	Height        int    `json:"height"`
	ScreenshotUrl string `xorm:"varchar(500)" json:"screenshotUrl"`
}

func GetPage

func GetPage(id string) *Page

func GetPages

func GetPages(websiteId string) []*Page

type Session

type Session struct {
	Id          string `xorm:"varchar(100) notnull pk" json:"id"`
	WebsiteId   string `xorm:"varchar(100) notnull pk" json:"websiteId"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UserAgent   string `xorm:"varchar(500)" json:"userAgent"`
	ClientIp    string `xorm:"varchar(100)" json:"clientIp"`
	UserId      string `xorm:"varchar(100)" json:"userId"`

	ImpressionCount int           `json:"impressionCount"`
	Impressions     []*Impression `json:"-"`

	Traces   []*Trace       `json:"traces"`
	TraceMap map[int]*Trace `json:"-"`

	TN int `json:"tn"`
	FP int `json:"fp"`
	FN int `json:"fn"`
	TP int `json:"tp"`
	UN int `json:"un"`
}

func GetSession

func GetSession(id string, websiteId string) *Session

func GetSessions

func GetSessions(websiteId string, resultCount int, offset int, sortField string, sortOrder string) []*Session

func NewSession

func NewSession(id string) *Session

func (*Session) AddTrace

func (ss *Session) AddTrace(t *Trace)

func (*Session) SyncStatistics

func (ss *Session) SyncStatistics()

func (*Session) ToJson

func (ss *Session) ToJson(ruleCount int) *SessionJson

type SessionJson

type SessionJson struct {
	Id string `json:"id"`

	ImpressionCount int `json:"impressionCount"`

	TN int `json:"tn"`
	FP int `json:"fp"`
	FN int `json:"fn"`
	TP int `json:"tp"`
	UN int `json:"un"`

	RuleCounts []int `json:"ruleCounts"`
}

type Trace

type Trace struct {
	Id           int    `json:"batchId"`
	PacketId     int    `json:"packetId"`
	Url          string `json:"url"`
	Path         string `json:"path"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	PageLoadTime string `json:"pageLoadTime"`
	Referrer     string `json:"referrer"`

	Label     int    `json:"label"`
	Guess     int    `json:"guess"`
	Reason    string `json:"reason"`
	RuleId    int    `json:"ruleId"`
	RuleStart int    `json:"ruleStart"`
	RuleEnd   int    `json:"ruleEnd"`

	Events []*Event `json:"events"`
}

func NewTrace

func NewTrace(id int) *Trace

func (*Trace) AddEvent

func (t *Trace) AddEvent(timestamp float64, typ string, button string, x int, y int)

func (*Trace) LoadFromJson

func (t *Trace) LoadFromJson(b []byte)

func (*Trace) SortEvents

func (t *Trace) SortEvents()

type TrackConfig

type TrackConfig struct {
	EndpointType   string `json:"endpointType"`
	UploadEndpoint string `json:"uploadEndpoint"`
	ResendInterval int    `json:"resendInterval"`

	UploadMode   string `json:"uploadMode"`
	UploadTimes  int    `json:"uploadTimes"`
	UploadPeriod int    `json:"uploadPeriod"`
	Frequency    int    `json:"frequency"`

	SizeLimit int    `json:"sizeLimit"`
	Scope     string `json:"scope"`
	EnableGet bool   `json:"enableGet"`
	Version   string `json:"version"`

	Encoder            string `json:"encoder"`
	EnableServerConfig bool   `json:"enableServerConfig"`
	DisableSession     bool   `json:"disableSession"`
}

func ParseTrackConfig

func ParseTrackConfig(s string) TrackConfig

type Website

type Website struct {
	Id   string `xorm:"varchar(100) notnull pk" json:"id"`
	Name string `xorm:"varchar(100)" json:"name"`

	Url         string `xorm:"varchar(100)" json:"url"`
	TrackConfig string `xorm:"mediumtext" json:"trackConfig"`

	State        string `xorm:"varchar(100)" json:"state"`
	SessionCount int    `json:"sessionCount"`
}

func GetWebsite

func GetWebsite(id string) *Website

func GetWebsites

func GetWebsites() []*Website

Jump to

Keyboard shortcuts

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