static

package
v0.0.0-...-5093999 Latest Latest
Warning

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

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

Documentation

Overview

Package static implements interfaces, types and constants used in the rest of the project modules.

Through this package, the others communicate with each other.

Index

Constants

View Source
const (
	SECURE_LVL_UNSECURE               uint = 0
	SECURE_LVL_ENCRYPTED                   = 1
	SECURE_LVL_VERIFIED                    = 2
	SECURE_LVL_ENCRYPTED_AND_VERIFIED      = 3
)

Most useful seurity levels

Variables

This section is empty.

Functions

func META_HEADER

func META_HEADER() []byte

Returns static header of first pkg in yggdrasil connection.

Types

type AllowList

type AllowList []ed25519.PublicKey

AllowList is a list of public keys of nodes that are allowed to communicate with the current.

AllowList can be equal to nil. This should be interpreted as a connection permission for any nodes.

func (*AllowList) IsAllow

func (a *AllowList) IsAllow(key ed25519.PublicKey) bool

Checks whether the passed key is in the allowed list.

If AllowList is nil, it always returns true.

type ConnClosedByDeduplicatorError

type ConnClosedByDeduplicatorError struct{}

func (ConnClosedByDeduplicatorError) Error

func (ConnClosedByDeduplicatorError) Temporary

func (e ConnClosedByDeduplicatorError) Temporary() bool

func (ConnClosedByDeduplicatorError) Timeout

func (e ConnClosedByDeduplicatorError) Timeout() bool

type ConnResult

type ConnResult struct {
	// The connection itself
	Conn net.Conn
	// Optional transport lvl public key (may be nil)
	Pkey ed25519.PublicKey
	// Lvl of connection security
	// Here is most used values:
	// - ytl.static.SECURE_LVL_UNSECURE
	// - ytl.static.SECURE_LVL_ENCRYPTED
	// - ytl.static.SECURE_LVL_VERIFIED
	// - ytl.static.SECURE_LVL_ENCRYPTED_AND_VERIFIED
	SecurityLevel uint
}

ConnResult contains information received when establishing a transport connection with another node

type ConnTimeoutError

type ConnTimeoutError struct{}

func (ConnTimeoutError) Error

func (e ConnTimeoutError) Error() string

func (ConnTimeoutError) Temporary

func (e ConnTimeoutError) Temporary() bool

func (ConnTimeoutError) Timeout

func (e ConnTimeoutError) Timeout() bool

type InapplicableProxyTypeError

type InapplicableProxyTypeError struct {
	Transport string
	Proxy     url.URL
}

func (InapplicableProxyTypeError) Error

func (InapplicableProxyTypeError) Temporary

func (e InapplicableProxyTypeError) Temporary() bool

func (InapplicableProxyTypeError) Timeout

func (e InapplicableProxyTypeError) Timeout() bool

type InvalidUriError

type InvalidUriError struct {
	Err string
}

func (InvalidUriError) Error

func (e InvalidUriError) Error() string

func (InvalidUriError) Temporary

func (e InvalidUriError) Temporary() bool

func (InvalidUriError) Timeout

func (e InvalidUriError) Timeout() bool

type IvalidPeerPublicKey

type IvalidPeerPublicKey struct {
	Text string
}

func (IvalidPeerPublicKey) Error

func (e IvalidPeerPublicKey) Error() string

func (IvalidPeerPublicKey) Temporary

func (e IvalidPeerPublicKey) Temporary() bool

func (IvalidPeerPublicKey) Timeout

func (e IvalidPeerPublicKey) Timeout() bool

type ProtoVersion

type ProtoVersion struct {
	Major uint8 // For now, it is always 0
	Minor uint8
}

ProtoVersion is the representation of yggdrasil protocol semantic version.

func PROTO_VERSION

func PROTO_VERSION() ProtoVersion

Returns current supported version of yggdrasil protocol. Its 0.4 now.

func (ProtoVersion) String

func (e ProtoVersion) String() string

type Transport

type Transport interface {
	// Returns URI scheme of current transport.
	// As example "tcp" or "tls".
	GetScheme() string
	// Establishes and returns a transport connection or returns an error.
	Connect(
		ctx context.Context, uri url.URL,
		proxy *url.URL, key ed25519.PrivateKey,
	) (ConnResult, error)
	// Returns listener object for accepting incoming transport connections.
	Listen(ctx context.Context, uri url.URL, key ed25519.PrivateKey) (TransportListener, error)
}

Abstract interface for all transports realisations like tcp/tls/etc.

type TransportListener

type TransportListener interface {
	// Accept waits for and returns the next connection to the listener.
	Accept() (net.Conn, error)

	// AcceptConn waits for and returns the next connection
	// with optional transport key to the listener.
	AcceptConn() (ConnResult, error)

	// Close closes the listener.
	// Any blocked Accept operations will be unblocked and return errors.
	Close() error

	// Addr returns the listener's network address.
	Addr() net.Addr
}

TransportListener is similar to net.Listener except extra "AcceptConn" metod.

func ListenerToTransportListener

func ListenerToTransportListener(linstener net.Listener, secLvl uint) TransportListener

Wraps regular net.Listener to TransportListener.

type TransportSecurityCheckError

type TransportSecurityCheckError struct {
	Expected ed25519.PublicKey
	Received ed25519.PublicKey
}

func (TransportSecurityCheckError) Error

func (TransportSecurityCheckError) Temporary

func (e TransportSecurityCheckError) Temporary() bool

func (TransportSecurityCheckError) Timeout

func (e TransportSecurityCheckError) Timeout() bool

type UnacceptableAddressError

type UnacceptableAddressError struct {
	Text string
}

func (UnacceptableAddressError) Error

func (e UnacceptableAddressError) Error() string

func (UnacceptableAddressError) Temporary

func (e UnacceptableAddressError) Temporary() bool

func (UnacceptableAddressError) Timeout

func (e UnacceptableAddressError) Timeout() bool

type UnknownProtoError

type UnknownProtoError struct{}

func (UnknownProtoError) Error

func (e UnknownProtoError) Error() string

func (UnknownProtoError) Temporary

func (e UnknownProtoError) Temporary() bool

func (UnknownProtoError) Timeout

func (e UnknownProtoError) Timeout() bool

type UnknownProtoVersionError

type UnknownProtoVersionError struct {
	Expected ProtoVersion
	Received ProtoVersion
}

func (UnknownProtoVersionError) Error

func (e UnknownProtoVersionError) Error() string

func (UnknownProtoVersionError) Temporary

func (e UnknownProtoVersionError) Temporary() bool

func (UnknownProtoVersionError) Timeout

func (e UnknownProtoVersionError) Timeout() bool

type UnknownSchemeError

type UnknownSchemeError struct {
	Scheme string
}

func (UnknownSchemeError) Error

func (e UnknownSchemeError) Error() string

func (UnknownSchemeError) Temporary

func (e UnknownSchemeError) Temporary() bool

func (UnknownSchemeError) Timeout

func (e UnknownSchemeError) Timeout() bool

Jump to

Keyboard shortcuts

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