Documentation
¶
Index ¶
- Variables
- func CheckLatency(avgRtt, currentRtt time.Duration) bool
- func ConstructURL(Http_scheme, DestHost, Http_path string, DestPort int) string
- func GeneratePayloadData(payLoadSize int) []byte
- func GetSleepTime(PacketStatus bool, Interval int, RTT time.Duration) time.Duration
- func IPSlideToString(IPSlide []string) string
- func ResolveDestHost(DestHost string) (DestAddr []net.IP, err error)
- type HttpStatusCode
- type InputVars
- type Packet
- type PacketDNS
- type PacketHTTP
- type PacketICMP
- type PacketTCP
- type Pinger
- type Statistics
Constants ¶
This section is empty.
Variables ¶
var HTTPStatusDescription = map[int]string{
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Early Hints",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
207: "Multi-Status",
208: "Already Reported",
226: "IM Used",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy (Deprecated)",
307: "Temporary Redirect",
308: "Permanent Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request Timeout",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Payload Too Large",
414: "URI Too Long",
415: "Unsupported Media Type",
416: "Range Not Satisfiable",
417: "Expectation Failed",
418: "I'm a teapot",
421: "Misdirected Request",
422: "Unprocessable Entity",
423: "Locked",
424: "Failed Dependency",
425: "Too Early",
426: "Upgrade Required",
428: "Precondition Required",
429: "Too Many Requests",
431: "Request Header Fields Too Large",
451: "Unavailable For Legal Reasons",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Timeout",
505: "HTTP Version Not Supported",
506: "Variant Also Negotiates",
507: "Insufficient Storage",
508: "Loop Detected",
510: "Not Extended",
511: "Network Authentication Required",
}
Functions ¶
func CheckLatency ¶
Func - Check Latency. If the AvgRTT is over 10ms and current RTT > 2 * AvgRTT -> High_Latency
func ConstructURL ¶
Construct URL
func GeneratePayloadData ¶
Func - Generate Payload Date []byte
func GetSleepTime ¶
Func - Get Sleep Time
func IPSlideToString ¶
resonved IPs []string -> string
Types ¶
type HttpStatusCode ¶ added in v1.2.0
HTTP Status Code Item
func (HttpStatusCode) Code2String ¶ added in v1.2.1
func (h HttpStatusCode) Code2String() string
type InputVars ¶
type InputVars struct {
Type string // Select one of these: tcp, icmp, http, dns
Count int // Default is 0 which means nonstop till interruption.
PayLoadSize int // Specific the payload. ICMP default payload is 32 bytes. TCP/HTTP have no payload by default.
Timeout int // default timeout is 4 seconds
Interval int // Interval is the wait time between each packet send. Default is 1s.
SourceHost string
DestHost string
DestPort int
Http_path string
Http_scheme string
Http_method string
Http_statusCodes []HttpStatusCode
Http_proxy string // e.g. "", "http://user:[email protected]:3128", "socks5://127.0.0.1:1080"
Icmp_DF bool // ipv4 only
Dns_query string
Dns_queryType string
Dns_Protocol string
}
CLI Input variables Struct
type Packet ¶
type Packet interface {
GetStatus() bool
GetRtt() time.Duration
UpdateStatistics(s Statistics)
GetType() string
GetSendTime() time.Time
}
Packet Interface
type PacketDNS ¶
type PacketDNS struct {
Type string
Status bool
Seq int
DestAddr string
DestHost string
SendTime time.Time
RTT time.Duration
Dns_query string
Dns_queryType string
Dns_protocol string
Dns_response string
// statistics
PacketsRecv int
PacketsSent int
PacketLoss float64
MinRtt time.Duration
MaxRtt time.Duration
AvgRtt time.Duration
// Status update
AdditionalInfo string
}
PacketDNS Struct
func DnsProbing ¶
func DnsProbing(Seq int, destHost string, Dns_query string, Dns_Protocol string, timeout int) (PacketDNS, error)
func DnsProbing
func (PacketDNS) GetSendTime ¶
func (*PacketDNS) UpdateStatistics ¶
func (pkt *PacketDNS) UpdateStatistics(s Statistics)
type PacketHTTP ¶
type PacketHTTP struct {
Type string
Status bool
Seq int
DestAddr string
DestHost string
DestPort int
PayLoadSize int
SendTime time.Time
RTT time.Duration
Http_path string
Http_scheme string
Http_response_code int
Http_response string
Http_method string
// statistics
PacketsRecv int
PacketsSent int
PacketLoss float64
MinRtt time.Duration
MaxRtt time.Duration
AvgRtt time.Duration
// Status update
AdditionalInfo string
}
PacketHTTP Struct
func HttpProbing ¶
func HttpProbing( Seq int, destHost string, destPort int, Http_path string, Http_scheme string, Http_method string, Http_statusCodes []HttpStatusCode, timeout int, proxyStr string, ) (PacketHTTP, error)
HttpProbing performs HTTP probing with the ability to choose HTTP methods and ignore certificate errors
func (PacketHTTP) GetRtt ¶
func (pkt PacketHTTP) GetRtt() time.Duration
func (PacketHTTP) GetSendTime ¶
func (pkt PacketHTTP) GetSendTime() time.Time
func (PacketHTTP) GetStatus ¶
func (pkt PacketHTTP) GetStatus() bool
func (PacketHTTP) GetType ¶
func (pkt PacketHTTP) GetType() string
func (*PacketHTTP) UpdateStatistics ¶
func (pkt *PacketHTTP) UpdateStatistics(s Statistics)
type PacketICMP ¶
type PacketICMP struct {
Type string
Status bool
Seq int
DestAddr string
DestHost string
PayLoadSize int
SendTime time.Time
RTT time.Duration
Icmp_DF bool
// statistics
PacketsRecv int
PacketsSent int
PacketLoss float64
MinRtt time.Duration
MaxRtt time.Duration
AvgRtt time.Duration
// Status update
AdditionalInfo string
}
PacketICMP Struct
func IcmpProbing ¶
func IcmpProbing(Seq int, destAddr string, destHost string, PayLoadSize int, Icmp_DF bool, timeout int, payload []byte) (PacketICMP, error)
func: IcmpProbing
func (PacketICMP) GetRtt ¶
func (pkt PacketICMP) GetRtt() time.Duration
func (PacketICMP) GetSendTime ¶
func (pkt PacketICMP) GetSendTime() time.Time
func (PacketICMP) GetStatus ¶
func (pkt PacketICMP) GetStatus() bool
func (PacketICMP) GetType ¶
func (pkt PacketICMP) GetType() string
func (*PacketICMP) UpdateStatistics ¶
func (pkt *PacketICMP) UpdateStatistics(s Statistics)
type PacketTCP ¶
type PacketTCP struct {
Type string
Status bool
Seq int
DestAddr string
DestHost string
DestPort int
PayLoadSize int
SendTime time.Time
RTT time.Duration
// statistics
PacketsRecv int
PacketsSent int
PacketLoss float64
MinRtt time.Duration
MaxRtt time.Duration
AvgRtt time.Duration
// Status update
AdditionalInfo string
}
PacketTCP Struct
func TcpProbing ¶ added in v1.0.1
func TcpProbing(ctx *context.Context, Seq int, destAddr string, desetHost string, destPort int, PayLoadSize int) (PacketTCP, error)
func: tcpProbing
func (PacketTCP) GetSendTime ¶
func (*PacketTCP) UpdateStatistics ¶
func (pkt *PacketTCP) UpdateStatistics(s Statistics)
type Pinger ¶
type Pinger struct {
// ************** General Fields **********************
// Input Vars
InputVars InputVars
// statistics
Stat Statistics
// statistics Mutex
StatsMu sync.RWMutex
// source IP details
SourceAddr string
SourceIpAddr net.IP
// destination IP details
DestAddr string
DestIpAddr net.IP
// OnSend is called when Pinger sends a packet (for future use only)
OnSend func(Packet)
// OnRecv is called when Pinger receives and processes a packet (for future use only)
OnRecv func(Packet)
// probeChan
ProbeChan chan Packet
// PingerEnd Signal (for future app interaction ONLY)
PingerEnd bool
}
Pinger Struct
func (*Pinger) Resolve ¶
Method (Pinger) - Resolve does the DNS lookup for the Pinger address and sets IP protocol.
func (*Pinger) UpdateStatistics ¶
Method (Pinger) - Update pinger statistics
type Statistics ¶
type Statistics struct {
// PacketsRecv is the number of packets received.
PacketsRecv int
// PacketsSent is the number of packets sent.
PacketsSent int
// PacketLoss is the percentage of packets lost.
PacketLoss float64
// MinRtt is the minimum round-trip time sent via this pinger.
MinRtt time.Duration
// MaxRtt is the maximum round-trip time sent via this pinger.
MaxRtt time.Duration
// AvgRtt is the average round-trip time sent via this pinger.
AvgRtt time.Duration
}
Statistics represent the stats of a currently running or finished pinger operation.
func (*Statistics) UpdatePacketLoss ¶
func (s *Statistics) UpdatePacketLoss()
Method (Statistics) - Update PacketLoss