Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(t *testing.T, condition bool, msg string, v ...interface{})
- func Equals(t *testing.T, exp, act interface{})
- func GenRandomDomain(length int, domain string) string
- func GenTrafficFromConfig(appController *AppController) error
- func NewDatabaseConnectionFromFile(dbfile string) error
- func OK(t *testing.T, err error)
- func RemoveStringInSlice(a string, list []string) []string
- func StringInSlice(a string, list []string) bool
- type Agent
- type AppConfig
- type AppController
- type DBHandler
- type DNSClient
- type DNSQuery
- type Event
- type JobConfig
- type LoadCaller
- type LoadManager
- type LoadParams
- type NodeInfo
- type NodeManager
- func (manager *NodeManager) AddNode(ip string, port string) error
- func (manager *NodeManager) Agents() (agents []Agent)
- func (manager *NodeManager) Call(event Event, data interface{}) error
- func (manager *NodeManager) GetEnabledStatusAgent() ([]Agent, error)
- func (manager *NodeManager) RemoveNode(ip string, port string) error
- func (manager *NodeManager) SyncDBForAgents() error
- func (manager *NodeManager) UpdateEnableStatusAgent(ip string, port string, enable bool) error
- func (manager *NodeManager) UpdateLiveStatusAgent(agent Agent, live bool) error
Constants ¶
const ( DefaultPort = "53" DefaultRandomLength = 0 DefaultQPS = 100 DefaultMaxQuery = 0 DefaultProtocol = "udp" )
Default value for benchmark
const ( StatusStart uint32 = 1 StatusRunning uint32 = 2 StatusStopping uint32 = 3 StatusStopped uint32 = 4 )
Status define the current dns loader running status
Variables ¶
var StatusToString = map[uint32]string{ StatusStart: "start", StatusRunning: "running", StatusStopping: "stopping", StatusStopped: "stopped", }
StatusToString store the status code to string info
Functions ¶
func GenRandomDomain ¶
GenRandomDomain will generate the random domain name with the fix length
func GenTrafficFromConfig ¶
func GenTrafficFromConfig(appController *AppController) error
GenTrafficFromConfig function will do traffic generate job from configuration
func NewDatabaseConnectionFromFile ¶
NewDatabaseConnectionFromFile create database from file
func RemoveStringInSlice ¶
RemoveStringInSlice find if string type object and remove it
func StringInSlice ¶
StringInSlice find if string type object a in a string list
Types ¶
type Agent ¶
type Agent struct { gorm.Model UUID string `json:"uuid"` IP string `json:"ip"` Port string `json:"port"` Live bool `json:"live"` Enable bool `json:"enable"` }
Agent save all agent information in sqlite table
func (Agent) IPAddrWithPort ¶
IPAddrWithPort return connect ip and port combination
type AppConfig ¶
type AppConfig struct { User string Password string AppSecrect string HTTPServer string ConfigFileName string ConfigFileHandler *ini.File }
AppConfig hold the configration from ini file
func NewAppConfigFromFile ¶
NewAppConfigFromFile read a appConfig.ini file from local file system and return the AppConfig object
type AppController ¶
type AppController struct { sync.RWMutex *JobConfig *AppConfig LoadManager LoadCaller Status uint32 IsMaster bool }
AppController hold all infomation and control interface for this app
func GetGlobalAppController ¶
func GetGlobalAppController() *AppController
GetGlobalAppController return current appAppController
func NewAppControllerFromFile ¶
func NewAppControllerFromFile(file string) (*AppController, error)
NewAppControllerFromFile load the AppController and save to global variable
func (*AppController) GetCurrentJobStatus ¶
func (config *AppController) GetCurrentJobStatus() uint32
GetCurrentJobStatus return current task running status
func (*AppController) GetCurrentJobStatusString ¶
func (config *AppController) GetCurrentJobStatusString() string
GetCurrentJobStatusString return the readable string
func (*AppController) SetCurrentJobStatus ¶
func (config *AppController) SetCurrentJobStatus(status uint32) error
SetCurrentJobStatus change the status of current task
type DBHandler ¶
DBHandler db manager
func (*DBHandler) CreateDNSQueryHistory ¶
func (dbHander *DBHandler) CreateDNSQueryHistory(appController *AppController) error
CreateDNSQueryHistory save a new dns query info
type DNSClient ¶
type DNSClient struct { Conn []net.Conn NumConn int Offset int // contains filtered or unexported fields }
DNSClient hold the loader configuration setting and connection
func NewDNSClient ¶
func NewDNSClient(app *AppController) (dnsclient *DNSClient, err error)
NewDNSClient create a new DNSClient instance
func (*DNSClient) InitPacket ¶
InitPacket init a packet for dns query data
type JobConfig ¶
type JobConfig struct { JobID string `json:"job_id" valid:"uuid,optional"` Duration string `json:"duration" valid:"-"` Protocol string `json:"protocol" valid:"in(tcp|udp),optional"` QPS uint32 `json:"qps" valid:"-"` ClientNumber int `json:"client_number" valid:"-"` MaxQuery uint64 `json:"max_query" valid:"-"` Server string `json:"server" valid:"ip,optional"` Port string `json:"port" valid:"port,optional"` Domain string `json:"domain" valid:"-"` EnableEDNS string `json:"edns_enable" valid:"-"` EnableDNSSEC string `json:"dnssec_enable" valid:"-"` DomainRandomLength int `json:"domain_random_length" valid:"-"` QueryType string `json:"query_type" valid:"-"` }
JobConfig hold the job appAppController
func NewDefaultJobConfig ¶
func NewDefaultJobConfig() *JobConfig
NewDefaultJobConfig create a init job for appConfigration
func (*JobConfig) ValidateJob ¶
ValidateJob validate the job config
type LoadCaller ¶
LoadCaller define the behavior of call processor
type LoadManager ¶
LoadManager define the behavior of dns benchmark loader
func NewDNSLoaderGenerator ¶
func NewDNSLoaderGenerator(param LoadParams) (LoadManager, error)
NewDNSLoaderGenerator will return a new instance of generator using param from GeneratorParam
type LoadParams ¶
type LoadParams struct { Caller LoadCaller Timeout time.Duration QPS uint32 Max uint64 ClientNumber int Protocol string Duration time.Duration }
LoadParams will be used to new a loader instance with this param
func (*LoadParams) Info ¶
func (param *LoadParams) Info() string
Info return the basic info of lodaer params
type NodeInfo ¶
type NodeInfo struct { Agent JobID string `json:"job_id" valid:"-"` Status string `json:"status" valid:"-"` Error string `json:"error" valid:"-"` }
NodeInfo hold current Node baisc info and job info
type NodeManager ¶
type NodeManager struct { DB *gorm.DB NodeInfos map[string]NodeInfo // contains filtered or unexported fields }
NodeManager define the node list when new config generated the manager will call the nodes one by one
func NewNodeManager ¶
func NewNodeManager() *NodeManager
NewNodeManager will create a new node manager
func (*NodeManager) AddNode ¶
func (manager *NodeManager) AddNode(ip string, port string) error
AddNode append a new ip to this node list
func (*NodeManager) Agents ¶
func (manager *NodeManager) Agents() (agents []Agent)
Agents get all agents info
func (*NodeManager) Call ¶
func (manager *NodeManager) Call(event Event, data interface{}) error
Call function will send data to all agents
func (*NodeManager) GetEnabledStatusAgent ¶
func (manager *NodeManager) GetEnabledStatusAgent() ([]Agent, error)
GetEnabledStatusAgent get all enabled status
func (*NodeManager) RemoveNode ¶
func (manager *NodeManager) RemoveNode(ip string, port string) error
RemoveNode will remove the ip from current list
func (*NodeManager) SyncDBForAgents ¶
func (manager *NodeManager) SyncDBForAgents() error
SyncDBForAgents sync db to current list
func (*NodeManager) UpdateEnableStatusAgent ¶
func (manager *NodeManager) UpdateEnableStatusAgent(ip string, port string, enable bool) error
UpdateEnableStatusAgent will enable or disable one agent when using benchmark
func (*NodeManager) UpdateLiveStatusAgent ¶
func (manager *NodeManager) UpdateLiveStatusAgent(agent Agent, live bool) error
UpdateLiveStatusAgent will set live or dead status on one agent when using benchmark