Documentation
¶
Overview ¶
Package types is a super-package that contains all library code that toversok would need to interact with. Such as data layer parsing, higher-level types such as relay information, and more.
This package exists to avoid import cycles, and to clean up all misc/"leaf" functions and types into one hierarchy.
As a general rule to avoid import cycles inside this package:
- Only import parent packages, don't import child packages
- Importing from a "sibling" package (up the tree) is allowed.
Index ¶
- Constants
- func IsContextDone(ctx context.Context) bool
- func Map[T, U any](ts []T, f func(T) U) []U
- func NormaliseAddr(addr netip.Addr) netip.Addr
- func NormaliseAddrPort(ap netip.AddrPort) netip.AddrPort
- func NormaliseAddrPortSlice(s []netip.AddrPort) []netip.AddrPort
- func NormaliseAddrSlice(s []netip.Addr) []netip.Addr
- func ParseAddrPort(b [18]byte) netip.AddrPort
- func PrettyAddrPortSlice(s []netip.AddrPort) string
- func PtrOr[T any](v *T, def T) T
- func PutAddrPort(ap netip.AddrPort) []byte
- func RandStringBytesMaskImprSrc(n int) string
- func ReadUint32(reader *bufio.Reader) (uint32, error)
- func SetSubtraction[T comparable](a, b []T) []T
- func SetUnion[T comparable](a, b []T) []T
- func SliceOrEmpty[T any](v []T) []T
- func SliceOrNil[T any](v []T) []T
- func WriteUint32(writer *bufio.Writer, v uint32) error
- type CCCKEY
- type Incomparable
- type LogonCallback
- type MetaConn
- type UDPConn
- type UDPConnCloseCatcher
Constants ¶
const LevelTrace slog.Level = -8
Variables ¶
This section is empty.
Functions ¶
func IsContextDone ¶
IsContextDone does a quick check on a context to see if its dead.
func Map ¶
func Map[T, U any](ts []T, f func(T) U) []U
Map is a generic slice mapping function taken from https://stackoverflow.com/a/71624929/8700553, since golang loves to not give its developers any usable tools.
func ParseAddrPort ¶
func PrettyAddrPortSlice ¶
func PutAddrPort ¶
func RandStringBytesMaskImprSrc ¶
RandStringBytesMaskImprSrc returns a random hexadecimal string of length n.
func ReadUint32 ¶
ReadUint32 reads an uint32 in big-endian order to the reader
func SetSubtraction ¶
func SetSubtraction[T comparable](a, b []T) []T
SetSubtraction returns the elements in `a` that aren't in `b`.
in set notation: a - b
func SetUnion ¶
func SetUnion[T comparable](a, b []T) []T
SetUnion returns a set of elements that were either in a and b in set notation: a u b
func SliceOrEmpty ¶
func SliceOrEmpty[T any](v []T) []T
func SliceOrNil ¶
func SliceOrNil[T any](v []T) []T
Types ¶
type Incomparable ¶
type Incomparable [0]func()
Incomparable is a zero-width incomparable type. If added as the first field in a struct, it marks that struct as not comparable (can't do == or be a map key) and usually doesn't add any width to the struct (unless the struct has only small fields).
Be making a struct incomparable, you can prevent misuse (prevent people from using ==), but also you can shrink generated binaries, as the compiler can omit equality funcs from the binary.
(Taken from the tailscale types library)
type LogonCallback ¶
type UDPConn ¶
type UDPConn interface { SetReadDeadline(t time.Time) error ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) Write(b []byte) (int, error) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error) Close() error }
UDPConn interface for actors.Stage to more easily deal with.
type UDPConnCloseCatcher ¶
func (*UDPConnCloseCatcher) Close ¶
func (c *UDPConnCloseCatcher) Close() error
Directories
¶
Path | Synopsis |
---|---|
Package control pertains to all code related to contacting, serving, and talking to control.
|
Package control pertains to all code related to contacting, serving, and talking to control. |
controlhttp
Package controlhttp pertains to implementing control interfaces in a HTTP client/dialer and server handler.
|
Package controlhttp pertains to implementing control interfaces in a HTTP client/dialer and server handler. |
Package dial contains an implementation of TCP/HTTP dialing.
|
Package dial contains an implementation of TCP/HTTP dialing. |
Package ifaces contains interface definitions commonly shared amongst code in `types`.
|
Package ifaces contains interface definitions commonly shared amongst code in `types`. |
Package key contains Session, Node, and Control key definitions, private and public, and associated functions.
|
Package key contains Session, Node, and Control key definitions, private and public, and associated functions. |
Package msgactor contains definitions for messages directly sent and received between actors of the toversok stage.
|
Package msgactor contains definitions for messages directly sent and received between actors of the toversok stage. |
Package msgcontrol contains types, constants, and interfaces related to control messages.
|
Package msgcontrol contains types, constants, and interfaces related to control messages. |
Package msgsess contains session message definitions and parsing methods, to be sent over relay or directly.
|
Package msgsess contains session message definitions and parsing methods, to be sent over relay or directly. |
Package relay contains all code necessary to establish a connection with a relay server, create a relay server, and communicate with one.
|
Package relay contains all code necessary to establish a connection with a relay server, create a relay server, and communicate with one. |
relayhttp
Package relayhttp contains an implementation of a relay server in HTTP.
|
Package relayhttp contains an implementation of a relay server in HTTP. |
Package stage contains some miscellaneous types required in both toversok and types/ifaces.
|
Package stage contains some miscellaneous types required in both toversok and types/ifaces. |
Package stun contains all the code pertaining to STUN resolution.
|
Package stun contains all the code pertaining to STUN resolution. |