Documentation ¶
Index ¶
- Variables
- func IsAgentFromUserAgent(userAgent string) bool
- type Agent
- type AgentIP
- type AgentIPEncoder
- type DB
- type IPCacheMap
- type KVDB
- type Manager
- func (this *Manager) AddIP(ip string, agentCode string)
- func (this *Manager) ContainsIP(ip string) bool
- func (this *Manager) Load() error
- func (this *Manager) LookupIP(ip string) (agentCode string)
- func (this *Manager) Loop() (hasNext bool, err error)
- func (this *Manager) LoopAll() error
- func (this *Manager) SetDB(db DB)
- func (this *Manager) Start()
- type Queue
- type SQLiteDB
Constants ¶
This section is empty.
Variables ¶
View Source
var AllAgents = []*Agent{ NewAgent("baidu", []string{".baidu.com."}, nil, []string{"Baidu"}), NewAgent("google", []string{".googlebot.com."}, nil, []string{"Google"}), NewAgent("bing", []string{".search.msn.com."}, nil, []string{"bingbot"}), NewAgent("sogou", []string{".sogou.com."}, nil, []string{"Sogou"}), NewAgent("youdao", []string{".163.com."}, nil, []string{"Youdao"}), NewAgent("yahoo", []string{".yahoo.com."}, nil, []string{"Yahoo"}), NewAgent("bytedance", []string{".bytedance.com."}, nil, []string{"Bytespider"}), NewAgent("sm", []string{".sm.cn."}, nil, []string{"YisouSpider"}), NewAgent("yandex", []string{".yandex.com.", ".yndx.net."}, nil, []string{"Yandex"}), NewAgent("semrush", []string{".semrush.com."}, nil, []string{"SEMrush"}), }
Functions ¶
func IsAgentFromUserAgent ¶
Types ¶
type Agent ¶
type Agent struct { Code string Keywords []string // user agent keywords // contains filtered or unexported fields }
type AgentIPEncoder ¶ added in v1.3.5
type AgentIPEncoder[T interface{ *AgentIP }] struct { }
func (*AgentIPEncoder[T]) Decode ¶ added in v1.3.5
func (this *AgentIPEncoder[T]) Decode(valueBytes []byte) (value T, err error)
func (*AgentIPEncoder[T]) Encode ¶ added in v1.3.5
func (this *AgentIPEncoder[T]) Encode(value T) ([]byte, error)
func (*AgentIPEncoder[T]) EncodeField ¶ added in v1.3.5
func (this *AgentIPEncoder[T]) EncodeField(value T, fieldName string) ([]byte, error)
func (*AgentIPEncoder[T]) EncodeKey ¶ added in v1.3.5
func (this *AgentIPEncoder[T]) EncodeKey(item *AgentIP) string
EncodeKey generate key for ip item
type IPCacheMap ¶
type IPCacheMap struct {
// contains filtered or unexported fields
}
func NewIPCacheMap ¶
func NewIPCacheMap(maxLen int) *IPCacheMap
func (*IPCacheMap) Add ¶
func (this *IPCacheMap) Add(ip string)
func (*IPCacheMap) Contains ¶
func (this *IPCacheMap) Contains(ip string) bool
type KVDB ¶ added in v1.3.5
type KVDB struct {
// contains filtered or unexported fields
}
func (*KVDB) InsertAgentIP ¶ added in v1.3.5
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager Agent管理器
func NewManager ¶
func NewManager() *Manager
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
type SQLiteDB ¶ added in v1.3.5
type SQLiteDB struct {
// contains filtered or unexported fields
}
func NewSQLiteDB ¶ added in v1.3.5
func (*SQLiteDB) InsertAgentIP ¶ added in v1.3.5
Click to show internal directories.
Click to hide internal directories.