util

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSHProtocolUDP           = SSHForwardingProtocol(0)
	SSHForwardingProtocolTCP = SSHForwardingProtocol(1)
)
View Source
const (
	SSHAFIpv4 = SSHForwardingAddressFamily(4)
	SSHAFIpv6 = SSHForwardingAddressFamily(6)
)
View Source
const (
	// Min is the minimum value allowed for a QUIC varint.
	Min = 0

	// Max is the maximum allowed value for a QUIC varint (2^62-1).
	Max = maxVarInt8
)

taken from the QUIC draft

Variables

This section is empty.

Functions

func AppendVarInt

func AppendVarInt(b []byte, i uint64) []byte

AppendVarInt appends i in the QUIC varint format.

func AppendVarIntWithLen

func AppendVarIntWithLen(b []byte, i uint64, length uint64) []byte

AppendVarIntWithLen append i in the QUIC varint format with the desired length.

func CertHasIPSANs

func CertHasIPSANs(cert *x509.Certificate) (bool, error)

returns true whether the certificat contains a SubjectAltName extension with at least one IP address record

func ConfigureLogger

func ConfigureLogger(logLevel string)

func DumpCertAndKeyToFiles

func DumpCertAndKeyToFiles(cert *x509.Certificate, pubkey crypto.PublicKey, privkey crypto.PrivateKey, certPath, keyPath string) error

func EqualFold

func EqualFold(s, t string) bool

copied from "net/http/internal/ascii" EqualFold is strings.EqualFold, ASCII only. It reports whether s and t are equal, ASCII-case-insensitively.

func ExpandTildeWithHomeDir

func ExpandTildeWithHomeDir(filepath string) string

func GenerateCert

func GenerateCert(priv crypto.PrivateKey) (*x509.Certificate, error)

func GenerateKey

func GenerateKey() (crypto.PublicKey, crypto.PrivateKey, error)

func JWTSigningMethodFromCryptoPubkey

func JWTSigningMethodFromCryptoPubkey(pubkey crypto.PublicKey) (jwt.SigningMethod, error)

func MinUint64

func MinUint64(a uint64, b uint64) uint64

func ParseSSHString

func ParseSSHString(buf Reader) (string, error)

func ReadVarInt

func ReadVarInt(r Reader) (uint64, error)

ReadVarInt reads a number in the QUIC varint format from r.

func SSHStringLen

func SSHStringLen(s string) int

func Sha256Fingerprint

func Sha256Fingerprint(in []byte) string

func VarIntLen

func VarIntLen(i uint64) uint64

VarIntLen determines the number of bytes that will be needed to write the number i.

func WriteSSHString

func WriteSSHString(out []byte, s string) (int, error)

Types

type AcceptQueue

type AcceptQueue[T any] struct {
	// contains filtered or unexported fields
}

Accept queue copied from https://github.com/quic-go/webtransport-go/blob/master/session.go

func NewAcceptQueue

func NewAcceptQueue[T any]() *AcceptQueue[T]

func (*AcceptQueue[T]) Add

func (q *AcceptQueue[T]) Add(str T)

func (*AcceptQueue[T]) Chan

func (q *AcceptQueue[T]) Chan() <-chan struct{}

func (*AcceptQueue[T]) Next

func (q *AcceptQueue[T]) Next() T

type BytesReadCloser

type BytesReadCloser struct {
	*bytes.Reader
}

func (*BytesReadCloser) Close

func (b *BytesReadCloser) Close() error

type ChannelID

type ChannelID = uint64

type ChannelNotFound

type ChannelNotFound struct {
	ChannelID ChannelID
}

func (ChannelNotFound) Error

func (e ChannelNotFound) Error() string

type DatagramSender

type DatagramSender interface {
	SendDatagram(p []byte) error
}

type DatagramsQueue

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

func NewDatagramsQueue

func NewDatagramsQueue(len uint64) *DatagramsQueue

func (*DatagramsQueue) Add

func (q *DatagramsQueue) Add(datagram []byte) bool

returns true if added, false otherwise

func (*DatagramsQueue) Next

func (q *DatagramsQueue) Next() []byte

func (*DatagramsQueue) WaitAdd

func (q *DatagramsQueue) WaitAdd(ctx context.Context, datagram []byte) error

returns nil if added, the context closing error (context.Cause(ctx)) otherwise

func (*DatagramsQueue) WaitNext

func (q *DatagramsQueue) WaitNext(ctx context.Context) ([]byte, error)

type InvalidConfig

type InvalidConfig struct {
	Field string
	Value string
}

func (InvalidConfig) Error

func (e InvalidConfig) Error() string

type InvalidSSHString

type InvalidSSHString struct {
	Reason error
}

func (InvalidSSHString) Error

func (e InvalidSSHString) Error() string

type JWTTokenString

type JWTTokenString struct {
	Token string
}

a JWT bearer token, encoded following the JWT specification

type OtherHTTPError

type OtherHTTPError struct {
	StatusCode int
	HasBody    bool
	Body       string
}

func (OtherHTTPError) Error

func (e OtherHTTPError) Error() string

type Reader

type Reader interface {
	io.ByteReader
	io.Reader
}

Reader implements both the io.ByteReader and io.Reader interfaces.

func NewReader

func NewReader(r io.Reader) Reader

NewReader returns a Reader for r. If r already implements both io.ByteReader and io.Reader, NewReader returns r. Otherwise, r is wrapped to add the missing interfaces.

type SSH3DatagramSenderFunc

type SSH3DatagramSenderFunc func(p []byte) error

sends an ssh3 datagram. The function must know the ID of the channel

type SSHForwardingAddressFamily

type SSHForwardingAddressFamily = uint64

type SSHForwardingProtocol

type SSHForwardingProtocol = uint64

type SyncMap

type SyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSyncMap

func NewSyncMap[K comparable, V any]() SyncMap[K, V]

func (*SyncMap[K, V]) Get

func (m *SyncMap[K, V]) Get(key K) (V, bool)

func (*SyncMap[K, V]) Insert

func (m *SyncMap[K, V]) Insert(key K, val V)

type Unauthorized

type Unauthorized struct{}

func (Unauthorized) Error

func (e Unauthorized) Error() string

type UnknownSSHPubkeyType

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

func (UnknownSSHPubkeyType) Error

func (m UnknownSSHPubkeyType) Error() string

type UserNotFound

type UserNotFound struct {
	Username string
}

func (UserNotFound) Error

func (e UserNotFound) Error() string

type Writer

type Writer interface {
	io.ByteWriter
	io.Writer
}

Writer implements both the io.ByteWriter and io.Writer interfaces.

func NewWriter

func NewWriter(w io.Writer) Writer

NewWriter returns a Writer for w. If r already implements both io.ByteWriter and io.Writer, NewWriter returns w. Otherwise, w is wrapped to add the missing interfaces.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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