types

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: BSD-3-Clause Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CID

type CID [tiger.Size]byte

CID (Client ID) globally and publicly identify a unique client and underlie client to client communication.

They are generated by hashing the (unencoded) PID with the session hash algorithm.

Hubs should register clients by CID. CID length follows the length of the hash algorithm used for the session. Clients must be prepared to handle CIDs of varying lengths.

func MustParseCID

func MustParseCID(s string) (out CID)

MustParseCID parses a base32 CID string and panics on error.

func MustParseCIDP

func MustParseCIDP(s string) *CID

MustParseCIDP is the same as MustParseCID, but returns a pointer to a new value.

func (CID) Base32

func (id CID) Base32() string

Base32 returns base32 representation of the CID.

func (*CID) FromBase32

func (id *CID) FromBase32(s string) error

FromBase32 parses CID from base32 encoding.

func (CID) Hash

func (id CID) Hash() CID

Hash returns a Tiger hash of the CID.

func (CID) IsZero

func (id CID) IsZero() bool

IsZero check if CID value is zero.

func (CID) MarshalADC

func (id CID) MarshalADC(buf *bytes.Buffer) error

MarshalADC implements adc.Marshaler.

func (CID) MarshalText

func (id CID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (CID) String

func (id CID) String() string

String returns base32 representation of the CID.

func (*CID) UnmarshalADC

func (id *CID) UnmarshalADC(s []byte) error

UnmarshalADC implements adc.Unmarshaler.

func (*CID) UnmarshalText

func (id *CID) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type PID

type PID = CID

PID (Private ID) globally identify a unique client.

They function during initial protocol negotiation to generate the CID and are invisible to other clients. PIDs should be generated in a way to avoid collisions, for example using the hash of the current time and primary network card MAC address if sufficient randomness cannot be generated.

Hubs and clients may not disclose PIDs to other clients; doing so weakens the security of the ADC network. Clients should should keep the same PID between sessions and hubs. PID length follows the length of the hash algorithm used for the session.

func NewPID

func NewPID() (id PID, err error)

NewPID generates a new Private ID using a cryptographic random source.

type SID

type SID [4]byte

SID (Session ID) appears in all communication that interacts with the hub. They identify a unique user on a single hub and are assigned by the hub during initial protocol negotiation. SIDs are 20 bits long and encoded using a 4-byte base32 encoded string.

func SIDFromInt

func SIDFromInt(v uint32) (id SID)

SIDFromInt converts a 20 bit integer to a SID.

func SIDFromString

func SIDFromString(s string) (id SID)

SIDFromString parses a 4-byte base32 encoded SID value. It panics on error.

func (SID) MarshalADC

func (id SID) MarshalADC(buf *bytes.Buffer) error

MarshalADC implements adc.Marshaler.

func (SID) String

func (id SID) String() string

func (*SID) UnmarshalADC

func (id *SID) UnmarshalADC(s []byte) error

UnmarshalADC implements adc.Unmarshaler.

Jump to

Keyboard shortcuts

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