io

package
v0.0.0-...-142450a Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPacketTooShort = errors.New("packet is too short to contain token")

Functions

func EmblemUDPServer

func EmblemUDPServer(signer gen.TokenGenerator, endorsements [][]byte, port int, timeout int64, c chan *net.UDPAddr, wg *sync.WaitGroup)

Emblem distributing UDP server. Listens to the given port and to the given channel. Sends emblems to every address it receives over the given channel, but each address only once per timeout.

func FromPacket

func FromPacket(packet []byte) (uint16, int, []byte, error)

Parses a packet that was assembled by PacketForToken and [Prep]. Returns the sequence number, number of tokens to be expected in total, and the token.

func PacketForToken

func PacketForToken(rawToken []byte, totalNum uint16) tokenPacket

Encodes a token that will be accompanied by totalNum many other tokens as a packet. Call [Prep] before sending the packet.

func UDPProbe

func UDPProbe(listenPort int, probeAddr *net.UDPAddr, timeout int64, resultsChan chan TokenSet)

Sends a zero-sized packet to the probe address and listens for a response on the given port. Any complete set of tokens is written to the result channel. Result channel will be closed by this method. Listens for timeout many seconds, even if it received one set of tokens already.

func WatchSyslog

func WatchSyslog(file *os.File, emblemPort int, c chan *net.UDPAddr)

Types

type EmblemRefresher

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

func MkRefresher

func MkRefresher(cfg *gen.EmblemConfig, threshold int64) *EmblemRefresher

Returns an instance of gen.TokenGenerator. Generates an emblem according to the given gen.EmblemConfig but only every threshold many seconds. Calls to SignToken() will return the most recently signed token.

func (*EmblemRefresher) SignToken

func (er *EmblemRefresher) SignToken() (jwt.Token, []byte, error)

type TokenSet

type TokenSet [][]byte

Jump to

Keyboard shortcuts

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