ping

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckURI

func CheckURI(uri string) (schema, host string, port int, matched bool)

CheckURI check uri

func GetIP

func GetIP(hostname string) string

GetIP ...

func UseCustomeDNS added in v0.1.1

func UseCustomeDNS(dns []string)

UseCustomeDNS will set the dns to default DNS resolver for global

Types

type HTTPing

type HTTPing struct {
	Method string
	// contains filtered or unexported fields
}

HTTPing ...

func NewHTTPing

func NewHTTPing(method string) *HTTPing

NewHTTPing return new HTTPing

func (*HTTPing) Result

func (ping *HTTPing) Result() *Result

Result return ping result

func (*HTTPing) SetTarget

func (ping *HTTPing) SetTarget(target *Target)

SetTarget ...

func (*HTTPing) Start

func (ping *HTTPing) Start() <-chan struct{}

Start ping

func (*HTTPing) Stop

func (ping *HTTPing) Stop()

Stop the tcping

type Ping

type Ping interface {
	Start() <-chan struct{}

	Host() string
	Port() int
	Protocol() Protocol
	Counter() int

	Stop()

	Result() Result
}

Ping is a ping interface

type Pinger

type Pinger interface {
	Start() <-chan struct{}
	Stop()
	Result() *Result
	SetTarget(target *Target)
}

Pinger is a ping interface

type Protocol

type Protocol int

Protocol ...

const (
	// TCP is tcp protocol
	TCP Protocol = iota
	// HTTP is http protocol
	HTTP
	// HTTPS is https protocol
	HTTPS
)

func NewProtocol

func NewProtocol(protocol string) (Protocol, error)

NewProtocol convert protocol stirng to Protocol

func (Protocol) String

func (protocol Protocol) String() string

type Result

type Result struct {
	Counter        int
	SuccessCounter int
	Target         *Target

	MinDuration   time.Duration
	MaxDuration   time.Duration
	TotalDuration time.Duration
}

Result ...

func (Result) Avg

func (result Result) Avg() time.Duration

Avg return the average time of ping

func (Result) Failed

func (result Result) Failed() int

Failed return failed counter

func (Result) String

func (result Result) String() string

type TCPing

type TCPing struct {
	// contains filtered or unexported fields
}

TCPing ...

func NewTCPing

func NewTCPing() *TCPing

NewTCPing return a new TCPing

func (TCPing) Result

func (tcping TCPing) Result() *Result

Result return the result

func (*TCPing) SetTarget

func (tcping *TCPing) SetTarget(target *Target)

SetTarget set target for TCPing

func (TCPing) Start

func (tcping TCPing) Start() <-chan struct{}

Start a tcping

func (*TCPing) Stop

func (tcping *TCPing) Stop()

Stop the tcping

type Target

type Target struct {
	Protocol Protocol
	Host     string
	Port     int

	Counter  int
	Interval time.Duration
	Timeout  time.Duration
}

Target is a ping

func (Target) String

func (target Target) String() string

Jump to

Keyboard shortcuts

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