Documentation
¶
Overview ¶
Package mocks contains mocks for internal/model interfaces.
Index ¶
- type Addr
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (int, error)
- type DNSDecoder
- func (e *DNSDecoder) DecodeHTTPS(reply []byte, queryID uint16) (*model.HTTPSSvc, error)
- func (e *DNSDecoder) DecodeLookupHost(qtype uint16, reply []byte, queryID uint16) ([]string, error)
- func (e *DNSDecoder) DecodeNS(reply []byte, queryID uint16) ([]*net.NS, error)
- func (e *DNSDecoder) DecodeReply(reply []byte) (*dns.Msg, error)
- type DNSEncoder
- type DNSTransport
- type Dialer
- type HTTPClient
- type HTTPTransport
- type Listener
- type Logger
- type QUICDialer
- type QUICEarlyConnection
- func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
- func (c *QUICEarlyConnection) CloseWithError(code quic.ApplicationErrorCode, reason string) error
- func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState
- func (s *QUICEarlyConnection) Context() context.Context
- func (s *QUICEarlyConnection) HandshakeComplete() context.Context
- func (c *QUICEarlyConnection) LocalAddr() net.Addr
- func (s *QUICEarlyConnection) NextConnection() quic.Connection
- func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error)
- func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error)
- func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
- func (s *QUICEarlyConnection) ReceiveMessage() ([]byte, error)
- func (c *QUICEarlyConnection) RemoteAddr() net.Addr
- func (s *QUICEarlyConnection) SendMessage(b []byte) error
- type QUICListener
- type Reader
- type Resolver
- func (r *Resolver) Address() string
- func (r *Resolver) CloseIdleConnections()
- func (r *Resolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error)
- func (r *Resolver) LookupHost(ctx context.Context, domain string) ([]string, error)
- func (r *Resolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)
- func (r *Resolver) Network() string
- type TLSConn
- type TLSDialer
- type TLSHandshaker
- type UDPLikeConn
- func (c *UDPLikeConn) Close() error
- func (c *UDPLikeConn) LocalAddr() net.Addr
- func (c *UDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error)
- func (c *UDPLikeConn) RemoteAddr() net.Addr
- func (c *UDPLikeConn) SetDeadline(t time.Time) error
- func (c *UDPLikeConn) SetReadBuffer(n int) error
- func (c *UDPLikeConn) SetReadDeadline(t time.Time) error
- func (c *UDPLikeConn) SetWriteDeadline(t time.Time) error
- func (c *UDPLikeConn) SyscallConn() (syscall.RawConn, error)
- func (c *UDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { MockRead func(b []byte) (int, error) MockWrite func(b []byte) (int, error) MockClose func() error MockLocalAddr func() net.Addr MockRemoteAddr func() net.Addr MockSetDeadline func(t time.Time) error MockSetReadDeadline func(t time.Time) error MockSetWriteDeadline func(t time.Time) error }
Conn is a mockable net.Conn.
func (*Conn) SetDeadline ¶
SetDeadline calls MockSetDeadline.
func (*Conn) SetReadDeadline ¶
SetReadDeadline calls MockSetReadDeadline.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline calls MockSetWriteDeadline.
type DNSDecoder ¶
type DNSDecoder struct { MockDecodeLookupHost func(qtype uint16, reply []byte, queryID uint16) ([]string, error) MockDecodeHTTPS func(reply []byte, queryID uint16) (*model.HTTPSSvc, error) MockDecodeNS func(reply []byte, queryID uint16) ([]*net.NS, error) MockDecodeReply func(reply []byte) (*dns.Msg, error) }
DNSDecoder allows mocking dnsx.DNSDecoder.
func (*DNSDecoder) DecodeHTTPS ¶
DecodeHTTPS calls MockDecodeHTTPS.
func (*DNSDecoder) DecodeLookupHost ¶
DecodeLookupHost calls MockDecodeLookupHost.
func (*DNSDecoder) DecodeReply ¶ added in v3.15.0
func (e *DNSDecoder) DecodeReply(reply []byte) (*dns.Msg, error)
DecodeReply calls MockDecodeReply.
type DNSEncoder ¶
type DNSEncoder struct {
MockEncode func(domain string, qtype uint16, padding bool) ([]byte, uint16, error)
}
DNSEncoder allows mocking dnsx.DNSEncoder.
type DNSTransport ¶
type DNSTransport struct { MockRoundTrip func(ctx context.Context, query []byte) ([]byte, error) MockRequiresPadding func() bool MockNetwork func() string MockAddress func() string MockCloseIdleConnections func() }
DNSTransport allows mocking dnsx.DNSTransport.
func (*DNSTransport) CloseIdleConnections ¶
func (txp *DNSTransport) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
func (*DNSTransport) RequiresPadding ¶
func (txp *DNSTransport) RequiresPadding() bool
RequiresPadding calls MockRequiresPadding.
type Dialer ¶
type Dialer struct { MockDialContext func(ctx context.Context, network, address string) (net.Conn, error) MockCloseIdleConnections func() }
Dialer is a mockable Dialer.
func (*Dialer) CloseIdleConnections ¶
func (d *Dialer) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
type HTTPClient ¶
type HTTPClient struct { MockDo func(req *http.Request) (*http.Response, error) MockCloseIdleConnections func() }
HTTPClient allows mocking an http.Client.
func (*HTTPClient) CloseIdleConnections ¶
func (txp *HTTPClient) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
type HTTPTransport ¶
type HTTPTransport struct { MockNetwork func() string MockRoundTrip func(req *http.Request) (*http.Response, error) MockCloseIdleConnections func() }
HTTPTransport mocks netxlite.HTTPTransport.
func (*HTTPTransport) CloseIdleConnections ¶
func (txp *HTTPTransport) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
func (*HTTPTransport) Network ¶
func (txp *HTTPTransport) Network() string
Network calls MockNetwork.
type Listener ¶
type Listener struct { // Accept allows mocking Accept. MockAccept func() (net.Conn, error) // Close allows mocking Close. MockClose func() error // Addr allows mocking Addr. MockAddr func() net.Addr }
Listener allows mocking a net.Listener.
type Logger ¶
type Logger struct { MockDebug func(message string) MockDebugf func(format string, v ...interface{}) MockInfo func(message string) MockInfof func(format string, v ...interface{}) MockWarn func(message string) MockWarnf func(format string, v ...interface{}) }
Logger allows mocking a logger.
type QUICDialer ¶
type QUICDialer struct { // MockDialContext allows mocking DialContext. MockDialContext func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) // MockCloseIdleConnections allows mocking CloseIdleConnections. MockCloseIdleConnections func() }
QUICDialer is a mockable netxlite.QUICDialer.
func (*QUICDialer) CloseIdleConnections ¶
func (qcd *QUICDialer) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
func (*QUICDialer) DialContext ¶
func (qcd *QUICDialer) DialContext(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)
DialContext calls MockDialContext.
type QUICEarlyConnection ¶ added in v3.15.0
type QUICEarlyConnection struct { MockAcceptStream func(context.Context) (quic.Stream, error) MockAcceptUniStream func(context.Context) (quic.ReceiveStream, error) MockOpenStream func() (quic.Stream, error) MockOpenStreamSync func(ctx context.Context) (quic.Stream, error) MockOpenUniStream func() (quic.SendStream, error) MockOpenUniStreamSync func(ctx context.Context) (quic.SendStream, error) MockLocalAddr func() net.Addr MockRemoteAddr func() net.Addr MockCloseWithError func(code quic.ApplicationErrorCode, reason string) error MockContext func() context.Context MockConnectionState func() quic.ConnectionState MockHandshakeComplete func() context.Context MockNextConnection func() quic.Connection MockSendMessage func(b []byte) error MockReceiveMessage func() ([]byte, error) }
QUICEarlyConnection is a mockable quic.EarlyConnection.
func (*QUICEarlyConnection) AcceptStream ¶ added in v3.15.0
func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error)
AcceptStream calls MockAcceptStream.
func (*QUICEarlyConnection) AcceptUniStream ¶ added in v3.15.0
func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
AcceptUniStream calls MockAcceptUniStream.
func (*QUICEarlyConnection) CloseWithError ¶ added in v3.15.0
func (c *QUICEarlyConnection) CloseWithError( code quic.ApplicationErrorCode, reason string) error
CloseWithError calls MockCloseWithError.
func (*QUICEarlyConnection) ConnectionState ¶ added in v3.15.0
func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState
ConnectionState calls MockConnectionState.
func (*QUICEarlyConnection) Context ¶ added in v3.15.0
func (s *QUICEarlyConnection) Context() context.Context
Context calls MockContext.
func (*QUICEarlyConnection) HandshakeComplete ¶ added in v3.15.0
func (s *QUICEarlyConnection) HandshakeComplete() context.Context
HandshakeComplete calls MockHandshakeComplete.
func (*QUICEarlyConnection) LocalAddr ¶ added in v3.15.0
func (c *QUICEarlyConnection) LocalAddr() net.Addr
LocalAddr class MockLocalAddr.
func (*QUICEarlyConnection) NextConnection ¶ added in v3.15.0
func (s *QUICEarlyConnection) NextConnection() quic.Connection
NextConnection calls MockNextConnection.
func (*QUICEarlyConnection) OpenStream ¶ added in v3.15.0
func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error)
OpenStream calls MockOpenStream.
func (*QUICEarlyConnection) OpenStreamSync ¶ added in v3.15.0
func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error)
OpenStreamSync calls MockOpenStreamSync.
func (*QUICEarlyConnection) OpenUniStream ¶ added in v3.15.0
func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error)
OpenUniStream calls MockOpenUniStream.
func (*QUICEarlyConnection) OpenUniStreamSync ¶ added in v3.15.0
func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
OpenUniStreamSync calls MockOpenUniStreamSync.
func (*QUICEarlyConnection) ReceiveMessage ¶ added in v3.15.0
func (s *QUICEarlyConnection) ReceiveMessage() ([]byte, error)
ReceiveMessage calls MockReceiveMessage.
func (*QUICEarlyConnection) RemoteAddr ¶ added in v3.15.0
func (c *QUICEarlyConnection) RemoteAddr() net.Addr
RemoteAddr calls MockRemoteAddr.
func (*QUICEarlyConnection) SendMessage ¶ added in v3.15.0
func (s *QUICEarlyConnection) SendMessage(b []byte) error
SendMessage calls MockSendMessage.
type QUICListener ¶
type QUICListener struct {
MockListen func(addr *net.UDPAddr) (model.UDPLikeConn, error)
}
QUICListener is a mockable netxlite.QUICListener.
func (*QUICListener) Listen ¶
func (ql *QUICListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error)
Listen calls MockListen.
type Resolver ¶
type Resolver struct { MockLookupHost func(ctx context.Context, domain string) ([]string, error) MockNetwork func() string MockAddress func() string MockCloseIdleConnections func() MockLookupHTTPS func(ctx context.Context, domain string) (*model.HTTPSSvc, error) MockLookupNS func(ctx context.Context, domain string) ([]*net.NS, error) }
Resolver is a mockable Resolver.
func (*Resolver) CloseIdleConnections ¶
func (r *Resolver) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
func (*Resolver) LookupHTTPS ¶
LookupHTTPS calls MockLookupHTTPS.
func (*Resolver) LookupHost ¶
LookupHost calls MockLookupHost.
type TLSConn ¶
type TLSConn struct { // Conn is the embedded mockable Conn. Conn // MockConnectionState allows to mock the ConnectionState method. MockConnectionState func() tls.ConnectionState // MockHandshakeContext allows to mock the HandshakeContext method. MockHandshakeContext func(ctx context.Context) error }
TLSConn allows to mock netxlite.TLSConn.
func (*TLSConn) ConnectionState ¶
func (c *TLSConn) ConnectionState() tls.ConnectionState
ConnectionState calls MockConnectionState.
type TLSDialer ¶
type TLSDialer struct { // MockCloseIdleConnections allows to mock the CloseIdleConnections method. MockCloseIdleConnections func() // MockDialTLSContext allows to mock the DialTLSContext method. MockDialTLSContext func(ctx context.Context, network, address string) (net.Conn, error) }
TLSDialer allows to mock netxlite.TLSDialer.
func (*TLSDialer) CloseIdleConnections ¶
func (d *TLSDialer) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
type TLSHandshaker ¶
type TLSHandshaker struct { MockHandshake func(ctx context.Context, conn net.Conn, config *tls.Config) ( net.Conn, tls.ConnectionState, error) }
TLSHandshaker is a mockable TLS handshaker.
type UDPLikeConn ¶
type UDPLikeConn struct { MockWriteTo func(p []byte, addr net.Addr) (int, error) MockClose func() error MockLocalAddr func() net.Addr MockRemoteAddr func() net.Addr MockSetDeadline func(t time.Time) error MockSetReadDeadline func(t time.Time) error MockSetWriteDeadline func(t time.Time) error MockReadFrom func(p []byte) (int, net.Addr, error) MockSyscallConn func() (syscall.RawConn, error) MockSetReadBuffer func(n int) error }
UDPLikeConn is an UDP conn used by QUIC.
func (*UDPLikeConn) LocalAddr ¶
func (c *UDPLikeConn) LocalAddr() net.Addr
LocalAddr calls MockLocalAddr.
func (*UDPLikeConn) RemoteAddr ¶
func (c *UDPLikeConn) RemoteAddr() net.Addr
RemoteAddr calls MockRemoteAddr.
func (*UDPLikeConn) SetDeadline ¶
func (c *UDPLikeConn) SetDeadline(t time.Time) error
SetDeadline calls MockSetDeadline.
func (*UDPLikeConn) SetReadBuffer ¶
func (c *UDPLikeConn) SetReadBuffer(n int) error
SetReadBuffer calls MockSetReadBuffer.
func (*UDPLikeConn) SetReadDeadline ¶
func (c *UDPLikeConn) SetReadDeadline(t time.Time) error
SetReadDeadline calls MockSetReadDeadline.
func (*UDPLikeConn) SetWriteDeadline ¶
func (c *UDPLikeConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline calls MockSetWriteDeadline.
func (*UDPLikeConn) SyscallConn ¶
func (c *UDPLikeConn) SyscallConn() (syscall.RawConn, error)
SyscallConn calls MockSyscallConn.