dialtesting

package
v1.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package dialtesting defined dialtesting tasks and task implements.

Index

Constants

View Source
const (
	StatusStop = "stop"

	ClassHTTP      = "HTTP"
	ClassTCP       = "TCP"
	ClassWebsocket = "WEBSOCKET"
	ClassICMP      = "ICMP"
	ClassDNS       = "DNS"
	ClassHeadless  = "BROWSER"

	ClassOther = "OTHER"
)
View Source
const (
	MaxTimeout = 10 * time.Second
	MaxHops    = 60
	MaxRetry   = 3
)
View Source
const MaxMsgSize = 15 * 1024 * 1024
View Source
const (
	PingTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DialResult

type DialResult struct {
	Success bool
	Reasons []string
}

type HTTPAdvanceOption

type HTTPAdvanceOption struct {
	RequestOptions *HTTPOptRequest     `json:"request_options,omitempty"`
	RequestBody    *HTTPOptBody        `json:"request_body,omitempty"`
	Certificate    *HTTPOptCertificate `json:"certificate,omitempty"`
	Proxy          *HTTPOptProxy       `json:"proxy,omitempty"`
	Secret         *HTTPSecret         `json:"secret,omitempty"`
	RequestTimeout string              `json:"request_timeout,omitempty"`
}

type HTTPOptAuth

type HTTPOptAuth struct {
	// basic auth
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type HTTPOptBody

type HTTPOptBody struct {
	BodyType string `json:"body_type,omitempty"`
	Body     string `json:"body,omitempty"`
}

type HTTPOptCertificate

type HTTPOptCertificate struct {
	IgnoreServerCertificateError bool   `json:"ignore_server_certificate_error,omitempty"`
	PrivateKey                   string `json:"private_key,omitempty"`
	Certificate                  string `json:"certificate,omitempty"`
	CaCert                       string `json:"ca,omitempty"`
}

type HTTPOptProxy

type HTTPOptProxy struct {
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

type HTTPOptRequest

type HTTPOptRequest struct {
	FollowRedirect bool              `json:"follow_redirect,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	Cookies        string            `json:"cookies,omitempty"`
	Auth           *HTTPOptAuth      `json:"auth,omitempty"`
}

type HTTPSecret

type HTTPSecret struct {
	NoSaveResponseBody bool `json:"not_save,omitempty"`
}

type HTTPSuccess

type HTTPSuccess struct {
	Body []*SuccessOption `json:"body,omitempty"`

	ResponseTime string `json:"response_time,omitempty"`

	Header     map[string][]*SuccessOption `json:"header,omitempty"`
	StatusCode []*SuccessOption            `json:"status_code,omitempty"`
	// contains filtered or unexported fields
}

type HTTPTask

type HTTPTask struct {
	ExternalID        string             `json:"external_id"`
	Name              string             `json:"name"`
	AK                string             `json:"access_key"`
	Method            string             `json:"method"`
	URL               string             `json:"url"`
	PostURL           string             `json:"post_url"`
	CurStatus         string             `json:"status"`
	Frequency         string             `json:"frequency"`
	Region            string             `json:"region"` // 冗余进来,便于调试
	OwnerExternalID   string             `json:"owner_external_id"`
	SuccessWhenLogic  string             `json:"success_when_logic"`
	SuccessWhen       []*HTTPSuccess     `json:"success_when"`
	Tags              map[string]string  `json:"tags,omitempty"`
	Labels            []string           `json:"labels,omitempty"`
	WorkspaceLanguage string             `json:"workspace_language,omitempty"`
	TagsInfo          string             `json:"tags_info,omitempty"`
	AdvanceOptions    *HTTPAdvanceOption `json:"advance_options,omitempty"`
	UpdateTime        int64              `json:"update_time,omitempty"`
	Option            map[string]string
	// contains filtered or unexported fields
}

func (*HTTPTask) AccessKey

func (t *HTTPTask) AccessKey() string

func (*HTTPTask) Check

func (t *HTTPTask) Check() error

func (*HTTPTask) CheckResult

func (t *HTTPTask) CheckResult() (reasons []string, succFlag bool)

func (*HTTPTask) Class

func (t *HTTPTask) Class() string

func (*HTTPTask) Clear

func (t *HTTPTask) Clear()

func (*HTTPTask) GetFrequency

func (t *HTTPTask) GetFrequency() string

func (*HTTPTask) GetHostName added in v1.1.12

func (t *HTTPTask) GetHostName() (string, error)

func (*HTTPTask) GetLineData

func (t *HTTPTask) GetLineData() string

func (*HTTPTask) GetOwnerExternalID

func (t *HTTPTask) GetOwnerExternalID() string

func (*HTTPTask) GetResults

func (t *HTTPTask) GetResults() (tags map[string]string, fields map[string]interface{})

func (*HTTPTask) GetTagsInfo added in v1.1.21

func (t *HTTPTask) GetTagsInfo() string

func (*HTTPTask) GetWorkspaceLanguage added in v1.1.21

func (t *HTTPTask) GetWorkspaceLanguage() string

func (*HTTPTask) ID

func (t *HTTPTask) ID() string

func (*HTTPTask) Init

func (t *HTTPTask) Init() error

func (*HTTPTask) InitDebug

func (t *HTTPTask) InitDebug() error

func (*HTTPTask) MetricName

func (t *HTTPTask) MetricName() string

func (*HTTPTask) PostURLStr

func (t *HTTPTask) PostURLStr() string

func (*HTTPTask) RegionName

func (t *HTTPTask) RegionName() string

func (*HTTPTask) Run

func (t *HTTPTask) Run() error

func (*HTTPTask) SetAk

func (t *HTTPTask) SetAk(ak string)

func (*HTTPTask) SetOwnerExternalID

func (t *HTTPTask) SetOwnerExternalID(exid string)

func (*HTTPTask) SetRegionID

func (t *HTTPTask) SetRegionID(regionID string)

func (*HTTPTask) SetStatus

func (t *HTTPTask) SetStatus(status string)

func (*HTTPTask) SetUpdateTime

func (t *HTTPTask) SetUpdateTime(ts int64)

func (*HTTPTask) Status

func (t *HTTPTask) Status() string

func (*HTTPTask) Stop

func (t *HTTPTask) Stop() error

func (*HTTPTask) Ticker

func (t *HTTPTask) Ticker() *time.Ticker

func (*HTTPTask) UpdateTimeUs

func (t *HTTPTask) UpdateTimeUs() int64

type ICMP

type ICMP struct {
	Type        uint8
	Code        uint8
	Checksum    uint16
	Identifier  uint16
	SequenceNum uint16
}

type ICMPSuccess

type ICMPSuccess struct {
	PacketLossPercent []*ValueSuccess       `json:"packet_loss_percent,omitempty"`
	ResponseTime      []*ResponseTimeSucess `json:"response_time,omitempty"`
	Hops              []*ValueSuccess       `json:"hops,omitempty"`
	Packets           []*ValueSuccess       `json:"packets,omitempty"`
}

type ICMPTask

type ICMPTask struct {
	Host              string            `json:"host"`
	PacketCount       int               `json:"packet_count"`
	Timeout           string            `json:"timeout"`
	EnableTraceroute  bool              `json:"enable_traceroute"`
	TracerouteConfig  *TracerouteOption `json:"traceroute_config"`
	SuccessWhen       []*ICMPSuccess    `json:"success_when"`
	SuccessWhenLogic  string            `json:"success_when_logic"`
	ExternalID        string            `json:"external_id"`
	Name              string            `json:"name"`
	AK                string            `json:"access_key"`
	PostURL           string            `json:"post_url"`
	CurStatus         string            `json:"status"`
	Frequency         string            `json:"frequency"`
	Region            string            `json:"region"`
	OwnerExternalID   string            `json:"owner_external_id"`
	Tags              map[string]string `json:"tags,omitempty"`
	Labels            []string          `json:"labels,omitempty"`
	UpdateTime        int64             `json:"update_time,omitempty"`
	WorkspaceLanguage string            `json:"workspace_language,omitempty"`
	TagsInfo          string            `json:"tags_info,omitempty"`
	// contains filtered or unexported fields
}

func (*ICMPTask) AccessKey

func (t *ICMPTask) AccessKey() string

func (*ICMPTask) Check

func (t *ICMPTask) Check() error

func (*ICMPTask) CheckResult

func (t *ICMPTask) CheckResult() (reasons []string, succFlag bool)

func (*ICMPTask) CheckSum

func (t *ICMPTask) CheckSum(data []byte) (rt uint16)

func (*ICMPTask) Class

func (t *ICMPTask) Class() string

func (*ICMPTask) Clear

func (t *ICMPTask) Clear()

func (*ICMPTask) GetFrequency

func (t *ICMPTask) GetFrequency() string

func (*ICMPTask) GetHostName added in v1.1.12

func (t *ICMPTask) GetHostName() (string, error)

func (*ICMPTask) GetLineData

func (t *ICMPTask) GetLineData() string

func (*ICMPTask) GetOwnerExternalID

func (t *ICMPTask) GetOwnerExternalID() string

func (*ICMPTask) GetResults

func (t *ICMPTask) GetResults() (tags map[string]string, fields map[string]interface{})

func (*ICMPTask) GetTagsInfo added in v1.1.21

func (t *ICMPTask) GetTagsInfo() string

func (*ICMPTask) GetWorkspaceLanguage added in v1.1.21

func (t *ICMPTask) GetWorkspaceLanguage() string

func (*ICMPTask) ID

func (t *ICMPTask) ID() string

func (*ICMPTask) Init

func (t *ICMPTask) Init() error

func (*ICMPTask) InitDebug

func (t *ICMPTask) InitDebug() error

func (*ICMPTask) MetricName

func (t *ICMPTask) MetricName() string

func (*ICMPTask) PostURLStr

func (t *ICMPTask) PostURLStr() string

func (*ICMPTask) RegionName

func (t *ICMPTask) RegionName() string

func (*ICMPTask) Run

func (t *ICMPTask) Run() error

func (*ICMPTask) SetAk

func (t *ICMPTask) SetAk(ak string)

func (*ICMPTask) SetOwnerExternalID

func (t *ICMPTask) SetOwnerExternalID(exid string)

func (*ICMPTask) SetRegionID

func (t *ICMPTask) SetRegionID(regionID string)

func (*ICMPTask) SetStatus

func (t *ICMPTask) SetStatus(status string)

func (*ICMPTask) SetUpdateTime

func (t *ICMPTask) SetUpdateTime(ts int64)

func (*ICMPTask) Status

func (t *ICMPTask) Status() string

func (*ICMPTask) Stop

func (t *ICMPTask) Stop() error

func (*ICMPTask) Ticker

func (t *ICMPTask) Ticker() *time.Ticker

func (*ICMPTask) UpdateTimeUs

func (t *ICMPTask) UpdateTimeUs() int64

type Packet

type Packet struct {
	ID  int
	Dst net.IP
	// contains filtered or unexported fields
}

Packet represent sent packet.

type Response

type Response struct {
	From         net.IP
	ResponseTime time.Duration
	// contains filtered or unexported fields
}

Response for sent packet, may be failed response when timeout.

type ResponseTimeSucess

type ResponseTimeSucess struct {
	Func   string `json:"func,omitempty"`
	Op     string `json:"op,omitempty"`
	Target string `json:"target,omitempty"`
	// contains filtered or unexported fields
}

type Route

type Route struct {
	Total   int          `json:"total"`
	Failed  int          `json:"failed"`
	Loss    float64      `json:"loss"`
	AvgCost float64      `json:"avg_cost"`
	MinCost float64      `json:"min_cost"`
	MaxCost float64      `json:"max_cost"`
	StdCost float64      `json:"std_cost"`
	Items   []*RouteItem `json:"items"`
}

Route is summary for each hop.

func TracerouteIP

func TracerouteIP(ip string, opt *TracerouteOption) (routes []*Route, err error)

type RouteItem

type RouteItem struct {
	IP           string  `json:"ip"`
	ResponseTime float64 `json:"response_time"`
}

RouteItem represent each retry response.

type SuccessOption

type SuccessOption struct {
	Is    string `json:"is,omitempty"`
	IsNot string `json:"is_not,omitempty"`

	MatchRegex    string `json:"match_regex,omitempty"`
	NotMatchRegex string `json:"not_match_regex,omitempty"`

	Contains    string `json:"contains,omitempty"`
	NotContains string `json:"not_contains,omitempty"`
	// contains filtered or unexported fields
}

type TCPResponseTime

type TCPResponseTime struct {
	IsContainDNS bool   `json:"is_contain_dns"`
	Target       string `json:"target"`
	// contains filtered or unexported fields
}

type TCPSuccess

type TCPSuccess struct {
	ResponseTime    []*TCPResponseTime `json:"response_time,omitempty"`
	Hops            []*ValueSuccess    `json:"hops,omitempty"`
	ResponseMessage []*SuccessOption   `json:"response_message,omitempty"`
}

type TCPTask

type TCPTask struct {
	Host              string            `json:"host"`
	Port              string            `json:"port"`
	Message           string            `json:"message"`
	Timeout           string            `json:"timeout"`
	EnableTraceroute  bool              `json:"enable_traceroute"`
	TracerouteConfig  *TracerouteOption `json:"traceroute_config"`
	SuccessWhen       []*TCPSuccess     `json:"success_when"`
	SuccessWhenLogic  string            `json:"success_when_logic"`
	ExternalID        string            `json:"external_id"`
	Name              string            `json:"name"`
	AK                string            `json:"access_key"`
	PostURL           string            `json:"post_url"`
	CurStatus         string            `json:"status"`
	Frequency         string            `json:"frequency"`
	Region            string            `json:"region"`
	OwnerExternalID   string            `json:"owner_external_id"`
	Tags              map[string]string `json:"tags,omitempty"`
	Labels            []string          `json:"labels,omitempty"`
	UpdateTime        int64             `json:"update_time,omitempty"`
	WorkspaceLanguage string            `json:"workspace_language,omitempty"`
	TagsInfo          string            `json:"tags_info,omitempty"`
	// contains filtered or unexported fields
}

func (*TCPTask) AccessKey

func (t *TCPTask) AccessKey() string

func (*TCPTask) Check

func (t *TCPTask) Check() error

func (*TCPTask) CheckResult

func (t *TCPTask) CheckResult() (reasons []string, succFlag bool)

func (*TCPTask) Class

func (t *TCPTask) Class() string

func (*TCPTask) Clear

func (t *TCPTask) Clear()

func (*TCPTask) GetFrequency

func (t *TCPTask) GetFrequency() string

func (*TCPTask) GetHostName added in v1.1.12

func (t *TCPTask) GetHostName() (string, error)

func (*TCPTask) GetLineData

func (t *TCPTask) GetLineData() string

func (*TCPTask) GetOwnerExternalID

func (t *TCPTask) GetOwnerExternalID() string

func (*TCPTask) GetResults

func (t *TCPTask) GetResults() (tags map[string]string, fields map[string]interface{})

func (*TCPTask) GetTagsInfo added in v1.1.21

func (t *TCPTask) GetTagsInfo() string

func (*TCPTask) GetWorkspaceLanguage added in v1.1.21

func (t *TCPTask) GetWorkspaceLanguage() string

func (*TCPTask) ID

func (t *TCPTask) ID() string

func (*TCPTask) Init

func (t *TCPTask) Init() error

func (*TCPTask) InitDebug

func (t *TCPTask) InitDebug() error

func (*TCPTask) MetricName

func (t *TCPTask) MetricName() string

func (*TCPTask) PostURLStr

func (t *TCPTask) PostURLStr() string

func (*TCPTask) RegionName

func (t *TCPTask) RegionName() string

func (*TCPTask) Run

func (t *TCPTask) Run() error

func (*TCPTask) SetAk

func (t *TCPTask) SetAk(ak string)

func (*TCPTask) SetOwnerExternalID

func (t *TCPTask) SetOwnerExternalID(exid string)

func (*TCPTask) SetRegionID

func (t *TCPTask) SetRegionID(regionID string)

func (*TCPTask) SetStatus

func (t *TCPTask) SetStatus(status string)

func (*TCPTask) SetUpdateTime

func (t *TCPTask) SetUpdateTime(ts int64)

func (*TCPTask) Status

func (t *TCPTask) Status() string

func (*TCPTask) Stop

func (t *TCPTask) Stop() error

func (*TCPTask) Ticker

func (t *TCPTask) Ticker() *time.Ticker

func (*TCPTask) UpdateTimeUs

func (t *TCPTask) UpdateTimeUs() int64

type Task

type Task interface {
	ID() string
	Status() string
	Run() error
	Init() error
	InitDebug() error
	CheckResult() ([]string, bool)
	Class() string
	GetResults() (map[string]string, map[string]interface{})
	PostURLStr() string
	MetricName() string
	Stop() error
	RegionName() string
	AccessKey() string
	Check() error
	UpdateTimeUs() int64
	GetFrequency() string
	GetOwnerExternalID() string
	SetOwnerExternalID(string)
	GetLineData() string
	GetHostName() (string, error)
	GetWorkspaceLanguage() string
	GetTagsInfo() string

	SetRegionID(string)
	SetAk(string)
	SetStatus(string)
	SetUpdateTime(int64)

	Ticker() *time.Ticker
}

type Traceroute

type Traceroute struct {
	Host    string
	Hops    int
	Retry   int
	Timeout time.Duration
	// contains filtered or unexported fields
}

Traceroute specified host with max hops and timeout.

func (*Traceroute) Run

func (t *Traceroute) Run() error

type TracerouteOption

type TracerouteOption struct {
	Hops    int
	Retry   int
	Timeout string
	// contains filtered or unexported fields
}

TracerouteOption represent traceroute option.

type ValueSuccess

type ValueSuccess struct {
	Op     string  `json:"op,omitempty"`
	Target float64 `json:"target,omitempty"`
}

type WebsocketAdvanceOption

type WebsocketAdvanceOption struct {
	RequestOptions *WebsocketOptRequest `json:"request_options,omitempty"`
	Auth           *WebsocketOptAuth    `json:"auth,omitempty"`
}

type WebsocketOptAuth

type WebsocketOptAuth struct {
	// basic auth
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type WebsocketOptRequest

type WebsocketOptRequest struct {
	Timeout string            `json:"timeout,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

type WebsocketResponseTime

type WebsocketResponseTime struct {
	IsContainDNS bool   `json:"is_contain_dns"`
	Target       string `json:"target"`
	// contains filtered or unexported fields
}

type WebsocketSuccess

type WebsocketSuccess struct {
	ResponseTime    []*WebsocketResponseTime    `json:"response_time,omitempty"`
	ResponseMessage []*SuccessOption            `json:"response_message,omitempty"`
	Header          map[string][]*SuccessOption `json:"header,omitempty"`
}

type WebsocketTask

type WebsocketTask struct {
	URL               string                  `json:"url"`
	Message           string                  `json:"message"`
	SuccessWhen       []*WebsocketSuccess     `json:"success_when"`
	AdvanceOptions    *WebsocketAdvanceOption `json:"advance_options,omitempty"`
	SuccessWhenLogic  string                  `json:"success_when_logic"`
	ExternalID        string                  `json:"external_id"`
	Name              string                  `json:"name"`
	AK                string                  `json:"access_key"`
	PostURL           string                  `json:"post_url"`
	CurStatus         string                  `json:"status"`
	Frequency         string                  `json:"frequency"`
	Region            string                  `json:"region"`
	OwnerExternalID   string                  `json:"owner_external_id"`
	Tags              map[string]string       `json:"tags,omitempty"`
	Labels            []string                `json:"labels,omitempty"`
	UpdateTime        int64                   `json:"update_time,omitempty"`
	WorkspaceLanguage string                  `json:"workspace_language,omitempty"`
	TagsInfo          string                  `json:"tags_info,omitempty"`
	// contains filtered or unexported fields
}

func (*WebsocketTask) AccessKey

func (t *WebsocketTask) AccessKey() string

func (*WebsocketTask) Check

func (t *WebsocketTask) Check() error

func (*WebsocketTask) CheckResult

func (t *WebsocketTask) CheckResult() (reasons []string, succFlag bool)

func (*WebsocketTask) Class

func (t *WebsocketTask) Class() string

func (*WebsocketTask) Clear

func (t *WebsocketTask) Clear()

func (*WebsocketTask) GetFrequency

func (t *WebsocketTask) GetFrequency() string

func (*WebsocketTask) GetHostName added in v1.1.12

func (t *WebsocketTask) GetHostName() (string, error)

func (*WebsocketTask) GetLineData

func (t *WebsocketTask) GetLineData() string

func (*WebsocketTask) GetOwnerExternalID

func (t *WebsocketTask) GetOwnerExternalID() string

func (*WebsocketTask) GetResults

func (t *WebsocketTask) GetResults() (tags map[string]string, fields map[string]interface{})

func (*WebsocketTask) GetTagsInfo added in v1.1.21

func (t *WebsocketTask) GetTagsInfo() string

func (*WebsocketTask) GetWorkspaceLanguage added in v1.1.21

func (t *WebsocketTask) GetWorkspaceLanguage() string

func (*WebsocketTask) ID

func (t *WebsocketTask) ID() string

func (*WebsocketTask) Init

func (t *WebsocketTask) Init() error

func (*WebsocketTask) InitDebug

func (t *WebsocketTask) InitDebug() error

func (*WebsocketTask) MetricName

func (t *WebsocketTask) MetricName() string

func (*WebsocketTask) PostURLStr

func (t *WebsocketTask) PostURLStr() string

func (*WebsocketTask) RegionName

func (t *WebsocketTask) RegionName() string

func (*WebsocketTask) Run

func (t *WebsocketTask) Run() error

func (*WebsocketTask) SetAk

func (t *WebsocketTask) SetAk(ak string)

func (*WebsocketTask) SetOwnerExternalID

func (t *WebsocketTask) SetOwnerExternalID(exid string)

func (*WebsocketTask) SetRegionID

func (t *WebsocketTask) SetRegionID(regionID string)

func (*WebsocketTask) SetStatus

func (t *WebsocketTask) SetStatus(status string)

func (*WebsocketTask) SetUpdateTime

func (t *WebsocketTask) SetUpdateTime(ts int64)

func (*WebsocketTask) Status

func (t *WebsocketTask) Status() string

func (*WebsocketTask) Stop

func (t *WebsocketTask) Stop() error

func (*WebsocketTask) Ticker

func (t *WebsocketTask) Ticker() *time.Ticker

func (*WebsocketTask) UpdateTimeUs

func (t *WebsocketTask) UpdateTimeUs() int64

Jump to

Keyboard shortcuts

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