web

package
v0.0.0-...-0dcc19d Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KAccess = KafkaAccess{Chan: make(chan Requests, 40960*2)}
	Address []string
	Num     int
	Thread  int

	KafkaOpen = 0
)
View Source
var (
	GeoFile     *geoip2.Reader
	Loc         *iploc.Locator
	NoGzip      = 0
	DefaultGzip = 1
	BestGzip    = 2
)

Functions

func Logging

func Logging() gin.HandlerFunc

func WebServer

func WebServer(addr string, gzipType int)

Types

type Buff

type Buff struct {
	Ch   chan Requests
	Size int
	File *os.File
}

type GeoData

type GeoData struct {
	Lat float64 `json:"lat"`
	Lon float64 `json:"lon"`
}

type KafkaAccess

type KafkaAccess struct {
	Size  int64
	Path  string
	Chan  chan Requests
	First int64
	Last  int64 // 上次发送信息
	Count int   // 数据总量
}

func (*KafkaAccess) RChan

func (access *KafkaAccess) RChan(id int)

读取channel并发送

func (*KafkaAccess) Send

func (access *KafkaAccess) Send(data []*sarama.ProducerMessage, client sarama.SyncProducer)

func (*KafkaAccess) Start

func (access *KafkaAccess) Start()

初始化

func (*KafkaAccess) Thread

func (access *KafkaAccess) Thread()

启动线程

func (*KafkaAccess) Topic

func (access *KafkaAccess) Topic() error

判断topic是否存在

type Requests

type Requests struct {
	TimeStamp string              `json:"timestamp"` // 访问时间
	Saddr     string              `json:"saddr"`     // 来源地址,一般是WAF地址
	Host      string              `json:"host"`      // host头,区分业务
	UA        string              `json:"ua"`        // UA头
	URI       string              `json:"uri"`       // uri
	Query     string              `json:"query"`     // uri里的查询参数
	Rule      string              `json:"rule"`      // 匹配上的规则,便于分类拦截
	XFF       string              `json:"xff"`       // X-Forwarded-For
	REF       string              `json:"ref"`       // referer
	Addr      string              `json:"addr"`      // X-Real-IP
	Method    string              `json:"method"`    // 请求方式
	APP       string              `json:"app"`       // 所属应用
	Headers   map[string][]string `json:"headers"`   // 完整头数据
	Status    int                 `json:"status"`    // 响应状态码
	Size      int                 `json:"size"`      // 响应包长度
	Body      string              `json:"body"`      // post body全包
	LRegion   string              `json:"region"`    // 组织
	LCountry  string              `json:"country"`   // 国家
	LProvince string              `json:"province"`  // 省份
	LCity     string              `json:"city"`      // 城市
	Local     string              `json:"localip"`   // 拦截中心地址
	Location  GeoData             `json:"Location"`  // 经纬度
}

Jump to

Keyboard shortcuts

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