debugstuff

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Overview

Package debugstuff implements mock structs & functions using in unit tests in whole project

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMockTransportInfo

func FormatMockTransportInfo(
	scheme string,
	uri url.URL,
	proxy *url.URL,
	ctx_closed bool,
	key ed25519.PrivateKey,
) string

Returns json string with passed arguments.

func MockConn

func MockConn() net.Conn

Return connection from witch valid handshake pkg & some pseudo payload data can be readed

func MockConnContent

func MockConnContent() []byte

Return valid handshake pkg & some pseudo payload data for debug usage

func MockConnTooShortContent

func MockConnTooShortContent() []byte

Returns an incorrect cropped ygg handshake pkg

func MockConnWrongVerContent

func MockConnWrongVerContent() []byte

Return valid handshake pkg & some pseudo payload data but proto version is too hight

func MockPubKey

func MockPubKey() []byte

Return valid ygg pub key for debug usage

func MockTooShortConn

func MockTooShortConn() net.Conn

Guess what by name

func MockWrongVerConn

func MockWrongVerConn() net.Conn

Guess what by name

func ReadMockTransportInfo

func ReadMockTransportInfo(conn net.Conn) string

Read all data from connetion up to EOF to string.

func ReadMockTransportInfoAfterHeader

func ReadMockTransportInfoAfterHeader(conn net.Conn) string

Read ygg handshake pkg and then all data up to EOF to string.

Types

type MockTransport

type MockTransport struct {
	Scheme    string
	SecureLvl uint
}

Mock realistion fro Transport interface for for debugging needs.

Has mutable behavior controlled by url keys.

func (MockTransport) Connect

func (t MockTransport) Connect(
	ctx context.Context,
	uri url.URL,
	proxy *url.URL,
	key ed25519.PrivateKey,
) (static.ConnResult, error)

Writes result of FormatMockTransportInfo to returned connection after handshake pkg

Peer key returned from opened connection controls by "mock_peer_key" url key. Transport key returned with opened connection controls by "mock_transport_key" url key. Delay before returning result controls by "mock_delay_conn" url key. Delay before writing handshake pkg to connection controls by "mock_delay_before_meta" url key. Delay before writing info string to connection controls by "mock_delay_after_meta" url key.

func (MockTransport) GetScheme

func (t MockTransport) GetScheme() string

func (MockTransport) Listen

type MockTransportListener

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

Mock realistion fro TransportListener interface for for debugging needs.

func (*MockTransportListener) Accept

func (l *MockTransportListener) Accept() (net.Conn, error)

func (*MockTransportListener) AcceptConn

func (l *MockTransportListener) AcceptConn() (static.ConnResult, error)

func (*MockTransportListener) Addr

func (l *MockTransportListener) Addr() net.Addr

func (*MockTransportListener) Close

func (l *MockTransportListener) Close() error

Jump to

Keyboard shortcuts

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