Documentation ¶
Overview ¶
Package mocks contains mocks for netx types.
Index ¶
- 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
- type DNSEncoder
- type DNSTransport
- type Dialer
- type HTTP3RoundTripper
- type HTTPClient
- type HTTPSSvc
- type HTTPTransport
- type Logger
- type QUICContextDialer
- type QUICDialer
- type QUICEarlySession
- func (s *QUICEarlySession) AcceptStream(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlySession) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
- func (c *QUICEarlySession) CloseWithError(code quic.ApplicationErrorCode, reason string) error
- func (s *QUICEarlySession) ConnectionState() quic.ConnectionState
- func (s *QUICEarlySession) Context() context.Context
- func (s *QUICEarlySession) HandshakeComplete() context.Context
- func (c *QUICEarlySession) LocalAddr() net.Addr
- func (s *QUICEarlySession) NextSession() quic.Session
- func (s *QUICEarlySession) OpenStream() (quic.Stream, error)
- func (s *QUICEarlySession) OpenStreamSync(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlySession) OpenUniStream() (quic.SendStream, error)
- func (s *QUICEarlySession) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
- func (s *QUICEarlySession) ReceiveMessage() ([]byte, error)
- func (c *QUICEarlySession) RemoteAddr() net.Addr
- func (s *QUICEarlySession) SendMessage(b []byte) error
- type QUICListener
- type QUICUDPLikeConn
- func (c *QUICUDPLikeConn) Close() error
- func (c *QUICUDPLikeConn) LocalAddr() net.Addr
- func (c *QUICUDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error)
- func (c *QUICUDPLikeConn) RemoteAddr() net.Addr
- func (c *QUICUDPLikeConn) SetDeadline(t time.Time) error
- func (c *QUICUDPLikeConn) SetReadBuffer(n int) error
- func (c *QUICUDPLikeConn) SetReadDeadline(t time.Time) error
- func (c *QUICUDPLikeConn) SetWriteDeadline(t time.Time) error
- func (c *QUICUDPLikeConn) SyscallConn() (syscall.RawConn, error)
- func (c *QUICUDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type Reader
- type Resolver
- type TLSConn
- type TLSDialer
- type TLSHandshaker
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) ([]string, error) MockDecodeHTTPS func(reply []byte) (*HTTPSSvc, error) }
DNSDecoder allows mocking dnsx.DNSDecoder.
func (*DNSDecoder) DecodeHTTPS ¶
func (e *DNSDecoder) DecodeHTTPS(reply []byte) (*HTTPSSvc, error)
DecodeHTTPS calls MockDecodeHTTPS.
func (*DNSDecoder) DecodeLookupHost ¶
func (e *DNSDecoder) DecodeLookupHost(qtype uint16, reply []byte) ([]string, error)
DecodeLookupHost calls MockDecodeLookupHost.
type DNSEncoder ¶
type DNSEncoder struct {
MockEncode func(domain string, qtype uint16, padding bool) ([]byte, error)
}
DNSEncoder allows mocking dnsx.DNSEncoder.
type DNSTransport ¶
type DNSTransport struct { MockRoundTrip func(ctx context.Context, query []byte) (reply []byte, err 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 HTTP3RoundTripper ¶
type HTTP3RoundTripper struct { MockRoundTrip func(req *http.Request) (*http.Response, error) MockClose func() error }
HTTP3RoundTripper allows mocking http3.RoundTripper.
func (*HTTP3RoundTripper) Close ¶
func (txp *HTTP3RoundTripper) Close() error
Close calls MockClose.
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 { MockRoundTrip func(req *http.Request) (*http.Response, error) MockCloseIdleConnections func() }
HTTPTransport mocks netxlite.HTTPTransport.
func (*HTTPTransport) CloseIdleConnections ¶
func (txp *HTTPTransport) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
type Logger ¶
type Logger struct { MockDebug func(message string) MockDebugf func(format string, v ...interface{}) }
Logger allows mocking a logger.
type QUICContextDialer ¶
type QUICContextDialer struct { MockDialContext func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) }
QUICContextDialer is a mockable netxlite.QUICContextDialer.
DEPRECATED: please use QUICDialer.
func (*QUICContextDialer) DialContext ¶
func (qcd *QUICContextDialer) DialContext(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error)
DialContext calls MockDialContext.
type QUICDialer ¶
type QUICDialer struct { // MockDialContext allows mocking DialContext. MockDialContext func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, 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.EarlySession, error)
DialContext calls MockDialContext.
type QUICEarlySession ¶
type QUICEarlySession 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 MockNextSession func() quic.Session MockSendMessage func(b []byte) error MockReceiveMessage func() ([]byte, error) }
QUICEarlySession is a mockable quic.EarlySession.
func (*QUICEarlySession) AcceptStream ¶
func (s *QUICEarlySession) AcceptStream(ctx context.Context) (quic.Stream, error)
AcceptStream calls MockAcceptStream.
func (*QUICEarlySession) AcceptUniStream ¶
func (s *QUICEarlySession) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
AcceptUniStream calls MockAcceptUniStream.
func (*QUICEarlySession) CloseWithError ¶
func (c *QUICEarlySession) CloseWithError( code quic.ApplicationErrorCode, reason string) error
CloseWithError calls MockCloseWithError.
func (*QUICEarlySession) ConnectionState ¶
func (s *QUICEarlySession) ConnectionState() quic.ConnectionState
ConnectionState calls MockConnectionState.
func (*QUICEarlySession) Context ¶
func (s *QUICEarlySession) Context() context.Context
Context calls MockContext.
func (*QUICEarlySession) HandshakeComplete ¶
func (s *QUICEarlySession) HandshakeComplete() context.Context
HandshakeComplete calls MockHandshakeComplete.
func (*QUICEarlySession) LocalAddr ¶
func (c *QUICEarlySession) LocalAddr() net.Addr
LocalAddr class MockLocalAddr.
func (*QUICEarlySession) NextSession ¶
func (s *QUICEarlySession) NextSession() quic.Session
NextSession calls MockNextSession.
func (*QUICEarlySession) OpenStream ¶
func (s *QUICEarlySession) OpenStream() (quic.Stream, error)
OpenStream calls MockOpenStream.
func (*QUICEarlySession) OpenStreamSync ¶
func (s *QUICEarlySession) OpenStreamSync(ctx context.Context) (quic.Stream, error)
OpenStreamSync calls MockOpenStreamSync.
func (*QUICEarlySession) OpenUniStream ¶
func (s *QUICEarlySession) OpenUniStream() (quic.SendStream, error)
OpenUniStream calls MockOpenUniStream.
func (*QUICEarlySession) OpenUniStreamSync ¶
func (s *QUICEarlySession) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
OpenUniStreamSync calls MockOpenUniStreamSync.
func (*QUICEarlySession) ReceiveMessage ¶
func (s *QUICEarlySession) ReceiveMessage() ([]byte, error)
ReceiveMessage calls MockReceiveMessage.
func (*QUICEarlySession) RemoteAddr ¶
func (c *QUICEarlySession) RemoteAddr() net.Addr
RemoteAddr calls MockRemoteAddr.
func (*QUICEarlySession) SendMessage ¶
func (s *QUICEarlySession) SendMessage(b []byte) error
SendMessage calls MockSendMessage.
type QUICListener ¶
type QUICListener struct {
MockListen func(addr *net.UDPAddr) (quicx.UDPLikeConn, error)
}
QUICListener is a mockable netxlite.QUICListener.
func (*QUICListener) Listen ¶
func (ql *QUICListener) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error)
Listen calls MockListen.
type QUICUDPLikeConn ¶
type QUICUDPLikeConn 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) (n int, addr net.Addr, err error) MockSyscallConn func() (syscall.RawConn, error) MockSetReadBuffer func(n int) error }
QUICUDPLikeConn is an UDP conn used by QUIC.
func (*QUICUDPLikeConn) LocalAddr ¶
func (c *QUICUDPLikeConn) LocalAddr() net.Addr
LocalAddr calls MockLocalAddr.
func (*QUICUDPLikeConn) RemoteAddr ¶
func (c *QUICUDPLikeConn) RemoteAddr() net.Addr
RemoteAddr calls MockRemoteAddr.
func (*QUICUDPLikeConn) SetDeadline ¶
func (c *QUICUDPLikeConn) SetDeadline(t time.Time) error
SetDeadline calls MockSetDeadline.
func (*QUICUDPLikeConn) SetReadBuffer ¶
func (c *QUICUDPLikeConn) SetReadBuffer(n int) error
SetReadBuffer calls MockSetReadBuffer.
func (*QUICUDPLikeConn) SetReadDeadline ¶
func (c *QUICUDPLikeConn) SetReadDeadline(t time.Time) error
SetReadDeadline calls MockSetReadDeadline.
func (*QUICUDPLikeConn) SetWriteDeadline ¶
func (c *QUICUDPLikeConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline calls MockSetWriteDeadline.
func (*QUICUDPLikeConn) SyscallConn ¶
func (c *QUICUDPLikeConn) SyscallConn() (syscall.RawConn, error)
SyscallConn calls MockSyscallConn.
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) (*HTTPSSvc, 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.