Documentation
¶
Index ¶
- type CheckType
- type Checker
- type HTTPChecker
- type ICMPChecker
- type ICMPv4
- func (p *ICMPv4) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)
- func (p *ICMPv4) MakeRequest(identifier, sequence uint16) ([]byte, error)
- func (p *ICMPv4) Network() string
- func (p *ICMPv4) SetDeadline(t time.Time) error
- func (p *ICMPv4) ValidateReply(reply []byte, identifier, sequence uint16) error
- type ICMPv6
- func (p *ICMPv6) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)
- func (p *ICMPv6) MakeRequest(identifier, sequence uint16) ([]byte, error)
- func (p *ICMPv6) Network() string
- func (p *ICMPv6) SetDeadline(t time.Time) error
- func (p *ICMPv6) ValidateReply(reply []byte, identifier, sequence uint16) error
- type Option
- func WithExpectedStatusCodes(codes []int) Option
- func WithHTTPHeaders(headers map[string]string) Option
- func WithHTTPMethod(method string) Option
- func WithHTTPSkipTLSVerify(skip bool) Option
- func WithHTTPTimeout(timeout time.Duration) Option
- func WithICMPReadTimeout(timeout time.Duration) Option
- func WithICMPWriteTimeout(timeout time.Duration) Option
- func WithTCPTimeout(timeout time.Duration) Option
- type OptionFunc
- type Protocol
- type TCPChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckType ¶
type CheckType string
CheckType represents the type of check to perform.
func GetCheckTypeFromString ¶
GetCheckTypeFromString converts a string to a CheckType enum.
type Checker ¶
type Checker interface { Check(ctx context.Context) error // Check performs a check and returns an error if the check fails. GetName() string // GetName returns the name of the checker. GetType() string // GetType returns the type of the checker. GetAddress() string // GetAddress returns the address of the checker. }
Checker defines an interface for performing various types of checks, such as TCP, HTTP, or ICMP. It provides methods for executing the check and obtaining a string representation of the checker.
type HTTPChecker ¶
type HTTPChecker struct {
// contains filtered or unexported fields
}
HTTPChecker implements the Checker interface for HTTP checks.
func (*HTTPChecker) GetAddress ¶
func (c *HTTPChecker) GetAddress() string
func (*HTTPChecker) GetName ¶
func (c *HTTPChecker) GetName() string
func (*HTTPChecker) GetType ¶
func (c *HTTPChecker) GetType() string
type ICMPChecker ¶
type ICMPChecker struct {
// contains filtered or unexported fields
}
ICMPChecker implements the Checker interface for ICMP checks.
func (*ICMPChecker) GetAddress ¶
func (c *ICMPChecker) GetAddress() string
func (*ICMPChecker) GetName ¶
func (c *ICMPChecker) GetName() string
func (*ICMPChecker) GetType ¶
func (c *ICMPChecker) GetType() string
type ICMPv4 ¶
type ICMPv4 struct {
// contains filtered or unexported fields
}
ICMPv4 implements the Protocol interface for IPv4 ICMP.
func (*ICMPv4) ListenPacket ¶
ListenPacket creates a new ICMPv4 packet connection.
func (*ICMPv4) MakeRequest ¶
MakeRequest creates an ICMP echo request message.
func (*ICMPv4) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
type ICMPv6 ¶
type ICMPv6 struct {
// contains filtered or unexported fields
}
ICMPv6 implements the Protocol interface for IPv6 ICMP.
func (*ICMPv6) ListenPacket ¶
ListenPacket creates a new ICMPv6 packet connection.
func (*ICMPv6) MakeRequest ¶
MakeRequest creates an ICMP echo request message.
func (*ICMPv6) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option defines a functional option for configuring a Checker.
func WithExpectedStatusCodes ¶
WithExpectedStatusCodes sets the expected status codes for the HTTPChecker.
func WithHTTPHeaders ¶
WithHTTPHeaders sets the HTTP headers for the HTTPChecker.
func WithHTTPMethod ¶
WithHTTPMethod sets the HTTP method for the HTTPChecker.
func WithHTTPSkipTLSVerify ¶
WithHTTPSkipTLSVerify sets the TLS verification flag for the HTTPChecker.
func WithHTTPTimeout ¶
WithHTTPTimeout sets the timeout for the HTTPChecker.
func WithICMPReadTimeout ¶
WithICMPReadTimeout sets the read timeout for the ICMPChecker.
func WithICMPWriteTimeout ¶
WithICMPWriteTimeout sets the write timeout for the ICMPChecker.
func WithTCPTimeout ¶
WithTCPTimeout sets the timeout for the TCPChecker.
type OptionFunc ¶
type OptionFunc func(Checker)
OptionFunc is a function that applies an Option to a Checker.
type Protocol ¶
type Protocol interface { // MakeRequest creates an ICMP echo request message with the specified identifier and sequence number. // Returns the serialized byte representation of the message or an error if message construction fails. MakeRequest(identifier, sequence uint16) ([]byte, error) // ValidateReply verifies that an ICMP echo reply message matches the expected identifier and sequence number. // Returns an error if the reply is invalid, such as a mismatch in identifier, sequence number, or unexpected message type. ValidateReply(reply []byte, identifier, sequence uint16) error // Network returns the network type string to be used for listening to ICMP packets, which typically indicates the IP // protocol version (e.g., "ip4:icmp" for IPv4 ICMP or "ip6:ipv6-icmp" for IPv6 ICMP). Network() string // ListenPacket sets up a listener for ICMP packets on the specified network and address, using the provided context. // Returns a net.PacketConn for reading and writing packets, or an error if the listener cannot be established. ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error) // SetDeadline sets the read and write deadlines for the packet connection, affecting any I/O operations on the connection. // Returns an error if setting the deadline fails. SetDeadline(t time.Time) error }
Protocol defines an interface for ICMP-based diagnostics, abstracting ICMPv4 and ICMPv6 behavior.
type TCPChecker ¶
type TCPChecker struct {
// contains filtered or unexported fields
}
TCPChecker implements the Checker interface for TCP checks.
func (*TCPChecker) GetAddress ¶
func (c *TCPChecker) GetAddress() string
func (*TCPChecker) GetName ¶
func (c *TCPChecker) GetName() string
func (*TCPChecker) GetType ¶
func (c *TCPChecker) GetType() string