ping

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LookupFunc func(string) (net.IP, error) = LookupIP

Functions

func LookupIP

func LookupIP(host string) (net.IP, error)

func LookupIPv4

func LookupIPv4(host string) (net.IP, error)

func LookupIPv6

func LookupIPv6(host string) (net.IP, error)

Types

type DnsPing added in v0.6.0

type DnsPing struct {
	Port    uint16
	Timeout time.Duration

	// udp, tcp, tcp-tls,默认 udp
	Net string

	// A, AAAA, NS, ...,默认 NS
	Type string

	// 查询域名,默认 .
	Domain string

	// Net 为 tcp-tls 时,是否跳过证书验证
	Insecure bool
	// contains filtered or unexported fields
}

func NewDnsPing added in v0.6.0

func NewDnsPing(host string, timeout time.Duration) *DnsPing

func (*DnsPing) Host added in v0.6.0

func (this *DnsPing) Host() string

func (*DnsPing) Ping added in v0.6.0

func (this *DnsPing) Ping() IPingResult

func (*DnsPing) PingContext added in v0.6.0

func (this *DnsPing) PingContext(ctx context.Context) IPingResult

func (*DnsPing) SetHost added in v0.6.0

func (this *DnsPing) SetHost(host string)

type DnsPingResult added in v0.6.0

type DnsPingResult struct {
	Time int
	Err  error
	IP   net.IP
}

func (*DnsPingResult) Error added in v0.6.0

func (this *DnsPingResult) Error() error

func (*DnsPingResult) Result added in v0.6.0

func (this *DnsPingResult) Result() int

func (*DnsPingResult) String added in v0.6.0

func (this *DnsPingResult) String() string

type HttpPing

type HttpPing struct {
	Method  string
	URL     string
	Timeout time.Duration

	// 以下参数全部为可选
	DisableHttp2       bool
	DisableCompression bool
	Insecure           bool
	Referrer           string
	UserAgent          string
	Http3              bool
	IP                 net.IP
}

func NewHttpPing

func NewHttpPing(method, url string, timeout time.Duration) *HttpPing

func (*HttpPing) Ping

func (this *HttpPing) Ping() IPingResult

func (*HttpPing) PingContext

func (this *HttpPing) PingContext(ctx context.Context) IPingResult

type HttpPingResult

type HttpPingResult struct {
	Time   int
	Proto  string
	Status int
	Length int
	Err    error
	IP     net.IP
}

func (*HttpPingResult) Error

func (this *HttpPingResult) Error() error

func (*HttpPingResult) Result

func (this *HttpPingResult) Result() int

func (*HttpPingResult) String

func (this *HttpPingResult) String() string

type IPing

type IPing interface {
	Ping() IPingResult
	PingContext(context.Context) IPingResult
}

type IPingResult

type IPingResult interface {
	Result() int
	Error() error
	fmt.Stringer
}

type IcmpPing

type IcmpPing struct {
	Timeout time.Duration

	Privileged bool
	TTL        int
	Size       int
	// contains filtered or unexported fields
}

func NewIcmpPing

func NewIcmpPing(host string, timeout time.Duration) *IcmpPing

func (*IcmpPing) Host

func (this *IcmpPing) Host() string

func (*IcmpPing) Ping

func (this *IcmpPing) Ping() IPingResult

func (*IcmpPing) PingContext

func (this *IcmpPing) PingContext(ctx context.Context) IPingResult

func (*IcmpPing) SetHost

func (this *IcmpPing) SetHost(host string)

type IcmpPingResult

type IcmpPingResult struct {
	Time int
	Err  error
	IP   net.IP
	TTL  int
}

func (*IcmpPingResult) Error

func (this *IcmpPingResult) Error() error

func (*IcmpPingResult) Result

func (this *IcmpPingResult) Result() int

func (*IcmpPingResult) String

func (this *IcmpPingResult) String() string

type QuicPing added in v0.8.0

type QuicPing struct {
	Host    string
	Port    uint16
	Timeout time.Duration

	// 以下为可选参数
	Insecure bool
	ALPN     string
	IP       net.IP
}

func NewQuicPing added in v0.8.0

func NewQuicPing(host string, port uint16, timeout time.Duration) *QuicPing

func (*QuicPing) Ping added in v0.8.0

func (this *QuicPing) Ping() IPingResult

func (*QuicPing) PingContext added in v0.8.0

func (this *QuicPing) PingContext(ctx context.Context) IPingResult

type QuicPingResult added in v0.8.0

type QuicPingResult struct {
	Time        int
	Err         error
	IP          net.IP
	QUICVersion uint32
	TLSVersion  uint16
}

func (*QuicPingResult) Error added in v0.8.0

func (this *QuicPingResult) Error() error

func (*QuicPingResult) Result added in v0.8.0

func (this *QuicPingResult) Result() int

func (*QuicPingResult) String added in v0.8.0

func (this *QuicPingResult) String() string

type TcpPing

type TcpPing struct {
	Port    uint16
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewTcpPing

func NewTcpPing(host string, port uint16, timeout time.Duration) *TcpPing

func (*TcpPing) Host

func (this *TcpPing) Host() string

func (*TcpPing) Ping

func (this *TcpPing) Ping() IPingResult

func (*TcpPing) PingContext

func (this *TcpPing) PingContext(ctx context.Context) IPingResult

func (*TcpPing) SetHost

func (this *TcpPing) SetHost(host string)

type TcpPingResult

type TcpPingResult struct {
	Time int
	Err  error
	IP   net.IP
}

func (*TcpPingResult) Error

func (this *TcpPingResult) Error() error

func (*TcpPingResult) Result

func (this *TcpPingResult) Result() int

func (*TcpPingResult) String

func (this *TcpPingResult) String() string

type TlsPing

type TlsPing struct {
	Host              string
	Port              uint16
	ConnectionTimeout time.Duration
	HandshakeTimeout  time.Duration

	// 以下为可选参数
	TlsVersion uint16
	Insecure   bool
	IP         net.IP
}

func NewTlsPing

func NewTlsPing(host string, port uint16, ct, ht time.Duration) *TlsPing

func (*TlsPing) Ping

func (this *TlsPing) Ping() IPingResult

func (*TlsPing) PingContext

func (this *TlsPing) PingContext(ctx context.Context) IPingResult

type TlsPingResult

type TlsPingResult struct {
	ConnectionTime int
	HandshakeTime  int
	TLSVersion     uint16
	Err            error
	IP             net.IP
}

func (*TlsPingResult) Error

func (this *TlsPingResult) Error() error

func (*TlsPingResult) Result

func (this *TlsPingResult) Result() int

func (*TlsPingResult) String

func (this *TlsPingResult) String() string

Jump to

Keyboard shortcuts

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