Documentation
¶
Overview ¶
Package zephyr provides a Go zephyr protocol implementation.
The Session API provides a high-level interface to the protocol and is one most users will likely use. The Dial functions create Sessions with default non-mock parameters and system-default parameters.
More specialized clients can use the lower-level Connection API which allows for more specialized handling of ACKs and message reassembly while implementing server discovery and retransmit schedule. There are also even lower-level notice-parsing functions for even lower-level clients.
Index ¶
- Constants
- Variables
- func DecodeZAscii(src []byte) ([]byte, error)
- func DecodeZAscii16(src []byte) (uint16, error)
- func DecodeZAscii32(src []byte) (uint32, error)
- func DecodeZAsciiInto(dst, src []byte) (int, error)
- func DecodeZcode(in []byte) ([]byte, error)
- func DecodedZAsciiLength(n int) int
- func EncodeMultipart(part, partof int) string
- func EncodeZAscii(src []byte) []byte
- func EncodeZAscii16(val uint16) []byte
- func EncodeZAscii32(val uint32) []byte
- func EncodeZcode(in []byte) []byte
- func EncodedZAsciiLength(n int) int
- func ParseMultipart(n *Notice) (int, int)
- func ReadNoticesFromServer(conn net.PacketConn, key *krb5.KeyBlock) <-chan NoticeReaderResult
- func ReadRawNotices(conn net.PacketConn) <-chan RawReaderResult
- type AuthStatus
- type Charset
- type Clock
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Credential() *krb5.Credential
- func (c *Connection) LocalAddr() *net.UDPAddr
- func (c *Connection) Notices() <-chan NoticeReaderResult
- func (c *Connection) RefreshServer() ([]*net.UDPAddr, error)
- func (c *Connection) SendNotice(ctx *krb5.Context, n *Notice) (*Notice, error)
- func (c *Connection) SendNoticeUnackedTo(n *Notice, addr net.Addr) error
- func (c *Connection) SendNoticeUnauth(n *Notice) (*Notice, error)
- func (c *Connection) SendPacket(pkt []byte, kind Kind, uid UID) (*Notice, error)
- func (c *Connection) SendPacketUnackedTo(pkt []byte, addr net.Addr) error
- type Header
- type Kind
- type Message
- type MessageReaderResult
- type Notice
- func DecodeRawNotice(r *RawNotice) (*Notice, error)
- func SendCancelSubscriptions(ctx *krb5.Context, conn *Connection, port uint16) (*Notice, error)
- func SendMessage(ctx *krb5.Context, conn *Connection, msg *Message) (*Notice, error)
- func SendMessageUnauth(conn *Connection, msg *Message) (*Notice, error)
- func SendSubscribe(ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription) (*Notice, error)
- func SendSubscribeNoDefaults(ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription) (*Notice, error)
- func SendUnsubscribe(ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription) (*Notice, error)
- func (n *Notice) EncodePacketForClient(ctx *krb5.Context, authstatus AuthStatus, key *krb5.KeyBlock) ([]byte, error)
- func (n *Notice) EncodePacketForServer(ctx *krb5.Context, cred *krb5.Credential) ([]byte, error)
- func (n *Notice) EncodePacketUnauth() []byte
- func (n *Notice) EncodeRawNoticeForClient(ctx *krb5.Context, authstatus AuthStatus, key *krb5.KeyBlock) (*RawNotice, error)
- func (n *Notice) EncodeRawNoticeForServer(ctx *krb5.Context, cred *krb5.Credential) (*RawNotice, error)
- func (n *Notice) EncodeRawNoticeUnauth() *RawNotice
- func (n *Notice) MakeACK(kind Kind, body string) *Notice
- type NoticeReaderResult
- type RawNotice
- func (r *RawNotice) CheckAuthFromClient(ctx *krb5.Context, service *krb5.Principal, keytab *krb5.KeyTab) (AuthStatus, *krb5.KeyBlock, error)
- func (r *RawNotice) CheckAuthFromServer(ctx *krb5.Context, key *krb5.KeyBlock) (AuthStatus, error)
- func (r *RawNotice) ChecksumPayload() []byte
- func (r *RawNotice) DecodeAuthStatus() (AuthStatus, error)
- func (r *RawNotice) DecodeAuthenticator() ([]byte, error)
- func (r *RawNotice) DecodeChecksum() ([]byte, error)
- func (r *RawNotice) EncodePacket() []byte
- type RawReaderResult
- type Reassembler
- type ServerConfig
- type Session
- func Dial(hesiod *hesiod.Hesiod, cred *krb5.Credential) (*Session, error)
- func DialSystemDefault() (*Session, error)
- func NewSession(conn net.PacketConn, server ServerConfig, cred *krb5.Credential) (*Session, error)
- func NewSessionFull(conn net.PacketConn, server ServerConfig, cred *krb5.Credential, clock Clock) (*Session, error)
- func (s *Session) Close() error
- func (s *Session) Credential() *krb5.Credential
- func (s *Session) LocalAddr() *net.UDPAddr
- func (s *Session) MakeUID(t time.Time) UID
- func (s *Session) Messages() <-chan MessageReaderResult
- func (s *Session) Port() uint16
- func (s *Session) Realm() string
- func (s *Session) SendCancelSubscriptions(ctx *krb5.Context) (*Notice, error)
- func (s *Session) SendMessage(ctx *krb5.Context, msg *Message) (*Notice, error)
- func (s *Session) SendMessageUnauth(msg *Message) (*Notice, error)
- func (s *Session) SendSubscribe(ctx *krb5.Context, subs []Subscription) (*Notice, error)
- func (s *Session) SendSubscribeNoDefaults(ctx *krb5.Context, subs []Subscription) (*Notice, error)
- func (s *Session) SendUnsubscribe(ctx *krb5.Context, subs []Subscription) (*Notice, error)
- func (s *Session) Sender() string
- type Subscription
- type UID
- type WindowedMap
Constants ¶
const ( ProtocolVersionMajor = 0 ProtocolVersionMinor = 2 )
ProtocolVersionMajor and ProtocolVersionMinor are the version of the zephyr protocol implemented by this library.
const MaxMessageBodyLength = 400000
MaxMessageBodyLength is the maximum length of a reassembled message body.
const MaxPacketLength = 1024
MaxPacketLength is the maximum size of a zephyr notice on the wire.
const WildcardInstance = "*"
WildcardInstance is the instance value used to subscribe to all instances for a given recipient, class pair.
Variables ¶
var ErrAuthenticatorLengthMismatch = errors.New("authenticator length mismatch")
ErrAuthenticatorLengthMismatch is returned when processing the authenticator on a RawNotice where the authlen field does not match the length of the decoded authenticator.
var ErrBadField = errors.New("bad field")
ErrBadField is returned if a field is in the wrong format.
var ErrBadPacketFieldCount = errors.New("bad field count")
ErrBadPacketFieldCount is returned when parsing a packet with a field count that does not match the content.
var ErrBadPacketFormat = errors.New("bad packet format")
ErrBadPacketFormat is returned when parsing a malformed packet.
var ErrBadPacketVersion = errors.New("incompatible packet version")
ErrBadPacketVersion is returned when parsing a packet with an incompatible version field.
var ErrBadVersionFormat = errors.New("bad version format")
ErrBadVersionFormat is returned when a zephyr version field cannot be parsed.
var ErrBodyFragmentOutOfBounds = errors.New("message fragment out of bounds")
ErrBodyFragmentOutOfBounds is returned if a notice's body is out of bounds of the reassembled message body.
var ErrBodyLengthMismatch = errors.New("reassembled body length mismatch")
ErrBodyLengthMismatch is returned if a notice's body length field is incompatible the reassembler being used.
var ErrBodyTooLong = errors.New("reassembled body too long")
ErrBodyTooLong is returned if the reassembled body is too long.
var ErrInvalidZcode = errors.New("invalid zcode")
ErrInvalidZcode is returned when decoding invalid zcode input.
var ErrPacketTooLong = errors.New("packet too long")
ErrPacketTooLong is returned when a notice or packet exceeds the maximum Zephyr packet size.
var ErrSendTimeout = errors.New("send timeout")
ErrSendTimeout is returned if a send times out without acknowledgement from the server.
var ErrUnknownEncType = errors.New("unknown enctype")
ErrUnknownEncType is returned when attempting to use a key with an unknown enctype.
var SystemClock systemClock
SystemClock is the real implementation of the Clock interface.
Functions ¶
func DecodeZAscii ¶
DecodeZAscii decodes zephyrascii and returns the decoded result as a byte slice.
func DecodeZAscii16 ¶
DecodeZAscii16 decodes the zephyrascii encoding of a 16-bit integer and returns the result as a uint16.
func DecodeZAscii32 ¶
DecodeZAscii32 decodes the zephyrascii encoding of a 32-bit integer and returns the result as a uint32.
func DecodeZAsciiInto ¶
DecodeZAsciiInto decodes zephyrascii from src and writes the output into dst. It returns the number of bytes written.
func DecodeZcode ¶
DecodeZcode decodes an input byte slice as zcode.
func DecodedZAsciiLength ¶
DecodedZAsciiLength returns the decoded length of a zephyrascii input of length n.
func EncodeMultipart ¶
EncodeMultipart encodes a pair of integers for the multipart field.
func EncodeZAscii ¶
EncodeZAscii encodes a byte slice as zephyrascii.
func EncodeZAscii16 ¶
EncodeZAscii16 encodes a 16-bit integer as zephyrascii.
func EncodeZAscii32 ¶
EncodeZAscii32 encodes a 32-bit integer as zephyrascii.
func EncodeZcode ¶
EncodeZcode encodes an input byte slice as zcode.
func EncodedZAsciiLength ¶
EncodedZAsciiLength returns the length of the zephyrascii encoding of a byte slice of length n.
func ParseMultipart ¶
ParseMultipart parses the multipart field of a notice. It returns the part and partof parts of the field. On parse error, it returns 0 and the length of the body.
func ReadNoticesFromServer ¶
func ReadNoticesFromServer( conn net.PacketConn, key *krb5.KeyBlock, ) <-chan NoticeReaderResult
ReadNoticesFromServer decodes and authenticates notices sent from the server. Returns a channel containing authenticated notices and errors. The channel is closed on fatal errors. If key is nil, all notices appear as AuthFailed.
func ReadRawNotices ¶
func ReadRawNotices(conn net.PacketConn) <-chan RawReaderResult
ReadRawNotices decodes packets from a PacketConn into RawNotices and returns a stream of them. Non-fatal errors are returned through the stream. On a fatal error or EOF, the channel is closed.
Types ¶
type AuthStatus ¶
type AuthStatus uint32
AuthStatus is the result of authenticating a notice.
const ( // AuthFailed describes a notice which failed authentication // for some reason. AuthFailed AuthStatus = 0xffffffff // AuthYes describes an authenticated notice. AuthYes AuthStatus = 1 // AuthNo describes a notice which did not claim to be // authenticated. AuthNo AuthStatus = 0 )
func (AuthStatus) String ¶
func (as AuthStatus) String() string
type Charset ¶
type Charset uint16
A Charset is the value of the "charset" field of a zephyr notice. Note that this field has a number of historical quirks. Only CharsetUTF8 or the byte-swapped version of it are really meaningful.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
A Connection represents a low-level connection to the Zephyr servers. It handles server discovery and sending and receiving Notices. It does not provide high-level constructs like subscribing or message sharding. It also does not automatically send CLIENTACKs.
func NewConnection ¶
func NewConnection( conn net.PacketConn, server ServerConfig, cred *krb5.Credential, ) (*Connection, error)
NewConnection creates a new Connection wrapping a given net.PacketConn. The ServerConfig argument instructs the connection on how to locate the remote servers. The Credential is used to authenticate incoming and outgoing packets. The connection takes ownership of the PacketConn and will close it when Close is called.
func NewConnectionFull ¶
func NewConnectionFull( conn net.PacketConn, server ServerConfig, cred *krb5.Credential, clock Clock, ) (*Connection, error)
NewConnectionFull does the same as NewConnection but takes an additional Clock argument for testing.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes the underlying connection.
func (*Connection) Credential ¶
func (c *Connection) Credential() *krb5.Credential
Credential returns the credential for this connection.
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() *net.UDPAddr
LocalAddr returns the local UDP address for the client when communicating with the Zephyr servers.
func (*Connection) Notices ¶
func (c *Connection) Notices() <-chan NoticeReaderResult
Notices returns the incoming notices from the connection.
func (*Connection) RefreshServer ¶
func (c *Connection) RefreshServer() ([]*net.UDPAddr, error)
RefreshServer forces a manual refresh of the server schedule from the ServerConfig. This will be called periodically and when outgoing messages time out, so there should be little need to call this manually.
func (*Connection) SendNotice ¶
SendNotice sends an authenticated notice to the servers. If the notice expects an acknowledgement, it returns the SERVACK or SERVNAK notice from the server on success.
func (*Connection) SendNoticeUnackedTo ¶
func (c *Connection) SendNoticeUnackedTo(n *Notice, addr net.Addr) error
SendNoticeUnackedTo sends an unauthenticated and unacked notice to a given destination. This is used to send a CLIENTACK to a received notice.
func (*Connection) SendNoticeUnauth ¶
func (c *Connection) SendNoticeUnauth(n *Notice) (*Notice, error)
SendNoticeUnauth sends an unauthenticated notice to the servers. If the notice expects an acknowledgement, it returns the SERVACK or SERVNAK notice from the server on success.
func (*Connection) SendPacket ¶
SendPacket sends a raw packet to the Zephyr servers. Based on kind and uid, it may wait for an acknowledgement. In that case, the SERVACK or SERVNAK notice will be returned. SendPacket rotates between the server instances and refreshes server list as necessary.
func (*Connection) SendPacketUnackedTo ¶
func (c *Connection) SendPacketUnackedTo(pkt []byte, addr net.Addr) error
SendPacketUnackedTo sends a raw packet to a given destination.
type Header ¶
type Header struct {
Kind Kind
UID UID
Port uint16
Class string
Instance string
OpCode string
Sender string
Recipient string
DefaultFormat string
SenderAddress net.IP
Charset Charset
OtherFields [][]byte
}
A Header is the set of common metadata between a Notice and a reassembled Message.
type Kind ¶
type Kind uint32
A Kind is the first field a zephyr notice.
const ( // UNSAFE notices are acknowledged by neither the server nor // the zhm (in implementations which use one). UNSAFE Kind = 0 // UNACKED notices are not acknowledged by the server. UNACKED Kind = 1 // ACKED notices are acknowledged by the server with a // SERVACK. ACKED Kind = 2 // HMACK notices are zhm acknowledgements. HMACK Kind = 3 // HMCTL notices are used in communications between the server // and the zhm. HMCTL Kind = 4 // SERVACK notices are acknowledgements from the server that a // notice was accepted for delivery. SERVACK Kind = 5 // SERVNAK notices are acknowledgements from the server that a // notice was received but not delivered for some reason. SERVNAK Kind = 6 // CLIENTACK notices are sent by the client to acknowledgement // a notice from the server. CLIENTACK Kind = 7 // STAT notices are used to request statistics from the zhm. STAT Kind = 8 )
func (Kind) ExpectsClientACK ¶
ExpectsClientACK returns whether the server expects a client acknowledgement in response to this packet.
func (Kind) ExpectsServerACK ¶
ExpectsServerACK returns whether the client expects a server acknowledgement in response to this packet.
func (Kind) IsServerACK ¶
IsServerACK returns whether this is a SERVACK or SERVNAK.
type Message ¶
A Message is a high-level reassembled zepyr message. This is the final stage of the messaging pipeline.
type MessageReaderResult ¶
type MessageReaderResult struct {
Message *Message
AuthStatus AuthStatus
}
A MessageReaderResult is an output of a Session's incoming Message channel. It either contains a Message with accompanying AuthStatus or an error.
type Notice ¶
A Notice is a raw message sent and received over zephyr.
func DecodeRawNotice ¶
DecodeRawNotice decodes a RawNotice into a Notice. The underlying byte slices on the result do not share backing stores with the RawNotice.
func SendCancelSubscriptions ¶
SendCancelSubscriptions uses a connection to close a session. The passed krb5 context is used to authenticate the request. The port number is the port to subscribe, or 0 to use the port of the connection.
func SendMessage ¶
SendMessage sends an authenticated message across a connection, sharding into multiple notices as needed. It returns the ACK from the server if the message is ACKED.
func SendMessageUnauth ¶
func SendMessageUnauth(conn *Connection, msg *Message) (*Notice, error)
SendMessageUnauth sends an unauthenticated message across a connection, sharding into multiple notices as needed. It returns the ACK from the server if the message is ACKED.
func SendSubscribe ¶
func SendSubscribe( ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription, ) (*Notice, error)
SendSubscribe uses a connection to subscribe to a list of subscriptions, along with any defaults configured on the server. The passed krb5 context is used to authenticate the request. The port number is the port to subscribe, or 0 to use the port of the connection.
func SendSubscribeNoDefaults ¶
func SendSubscribeNoDefaults( ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription, ) (*Notice, error)
SendSubscribeNoDefaults uses a connection to subscribe to a list of subscriptions. The passed krb5 context is used to authenticate the request. The port number is the port to subscribe, or 0 to use the port of the connection.
func SendUnsubscribe ¶
func SendUnsubscribe( ctx *krb5.Context, conn *Connection, port uint16, subs []Subscription, ) (*Notice, error)
SendUnsubscribe uses a connection to unsubscribe from a list of subscriptions. The passed krb5 context is used to authenticate the request. The port number is the port to subscribe, or 0 to use the port of the connection.
func (*Notice) EncodePacketForClient ¶
func (n *Notice) EncodePacketForClient( ctx *krb5.Context, authstatus AuthStatus, key *krb5.KeyBlock) ([]byte, error)
EncodePacketForClient encodes and authenticates a Notice to be sent to a client. Returns a packet.
func (*Notice) EncodePacketForServer ¶
EncodePacketForServer encodes and authenticates a Notice to be sent to a server. Returns a packet.
func (*Notice) EncodePacketUnauth ¶
EncodePacketUnauth encodes a Notice into an unauthenticated packet.
func (*Notice) EncodeRawNoticeForClient ¶
func (n *Notice) EncodeRawNoticeForClient( ctx *krb5.Context, authstatus AuthStatus, key *krb5.KeyBlock) (*RawNotice, error)
EncodeRawNoticeForClient encodes and authenticates a Notice to send to a client using a pre-negotiated session key. Returns a RawNotice.
func (*Notice) EncodeRawNoticeForServer ¶
func (n *Notice) EncodeRawNoticeForServer( ctx *krb5.Context, cred *krb5.Credential) (*RawNotice, error)
EncodeRawNoticeForServer encodes a Notice into an authenticated RawNotice to send to the server. Returns the RawNotice. The authenticator always negotiates the key in the credential.
TODO(davidben): Go back to returning the krb5.KeyBlock output from the API? Unless we negotiate a subkey, it's guaranteed to be the key in the credential anyway, and shared subscriptions require this to be true.
func (*Notice) EncodeRawNoticeUnauth ¶
EncodeRawNoticeUnauth encodes a Notice into an unauthenticated RawNotice.
func (*Notice) MakeACK ¶
MakeACK creates an acknowledgement notice for this message. Like libzephyr, this preserves the non-body header fields in the notice. This is not necessary for a CLIENTACK but is necessary for a SERVACK; clients like BarnOwl don't bother associating SERVACKs with outgoing messages and just trust the values in the SERVACK.
TODO(davidben): Unlike libzephyr, this doesn't preserve the checksum and authenticator. This should be fine. In fact, we can even authenticate ACKs without breaking anything.
type NoticeReaderResult ¶
type NoticeReaderResult struct {
Notice *Notice
AuthStatus AuthStatus
Addr net.Addr
}
A NoticeReaderResult is an output of a ReadNoticesFromServer call. It either contains a notice with authentication status and source address or an error.
type RawNotice ¶
A RawNotice is the first stage of processing a packet. The individual header fields are parsed out to extract a checksum and authenticator. The other fields are uninterpreted.
func DecodePacket ¶
DecodePacket records a packet into a RawNotice.
func (*RawNotice) CheckAuthFromClient ¶
func (r *RawNotice) CheckAuthFromClient( ctx *krb5.Context, service *krb5.Principal, keytab *krb5.KeyTab, ) (AuthStatus, *krb5.KeyBlock, error)
CheckAuthFromClient is called by a server to check a packet from a client using a server KeyTab. If successful, the session key from the client's authenticator is returned.
func (*RawNotice) CheckAuthFromServer ¶
func (r *RawNotice) CheckAuthFromServer( ctx *krb5.Context, key *krb5.KeyBlock, ) (AuthStatus, error)
CheckAuthFromServer is called by a client to check a packet from the server using a previously negotiated key.
func (*RawNotice) ChecksumPayload ¶
ChecksumPayload returns the portion of the packet that is checksumed. (The checksum itself is removed and the remainder is concatenated.)
func (*RawNotice) DecodeAuthStatus ¶
func (r *RawNotice) DecodeAuthStatus() (AuthStatus, error)
DecodeAuthStatus decodes the authstate field of a RawNotice.
func (*RawNotice) DecodeAuthenticator ¶
DecodeAuthenticator decodes the authenticator field of a RawNotice.
func (*RawNotice) DecodeChecksum ¶
DecodeChecksum decodes the checksum field of a RawNotice.
func (*RawNotice) EncodePacket ¶
EncodePacket encodes a RawNotice as a packet. If it is to be authenticated, the checksum and (if a client) authenticator fields must be already populated.
type RawReaderResult ¶
A RawReaderResult is an output of a ReadRawNotices call. It either contains a RawNotice and a source address or an error.
type Reassembler ¶
type Reassembler struct {
// contains filtered or unexported fields
}
Reassembler maintains state for a reassembled notice.
func NewReassembler ¶
func NewReassembler(length int) *Reassembler
NewReassembler creates a Reassembler for a message with a given body length.
func NewReassemblerFromMultipartField ¶
func NewReassemblerFromMultipartField(n *Notice) (*Reassembler, error)
NewReassemblerFromMultipartField creates a Reassembler for a given notice's multipart field. Note that this does not call AddNotice.
func (*Reassembler) AddNotice ¶
func (r *Reassembler) AddNotice(n *Notice, authStatus AuthStatus) error
AddNotice adds a notice into the reassembler state. If the notice is incompatible and discarded, it returns an error.
func (*Reassembler) Done ¶
func (r *Reassembler) Done() bool
Done returns true when the message body has been reassembled.
func (*Reassembler) Message ¶
func (r *Reassembler) Message() (*Message, AuthStatus)
Message returns the reassembled message once it is done.
type ServerConfig ¶
type ServerConfig interface {
// ResolveServer returns a list of zephyrd addresses to
// round-robin connect to. This may be repeatedly to refresh
// this list. ResolveServer cannot return a list of length 0.
ResolveServer() ([]*net.UDPAddr, error)
}
A ServerConfig describes how to connect to a given zephyrd instance.
func NewServerFromHesiod ¶
func NewServerFromHesiod(hs *hesiod.Hesiod) (ServerConfig, error)
NewServerFromHesiod creates the server configuration for a zephyr installation at a Hesiod realm.
func NewStaticServer ¶
func NewStaticServer(addrs []*net.UDPAddr) ServerConfig
NewStaticServer returns a ServerConfig which returns a static list of zephyr server addresses.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A Session is a high-level connection to the zephyr servers. It handles reassembly of sharded messages, ACKs, and deduplicating notices by UID. This API should be used by most zephyr clients.
func DialSystemDefault ¶
DialSystemDefault opens a new Session using credentials from the default ccache and using the system-wide Hesiod config to find the zephyrds.
func NewSession ¶
func NewSession( conn net.PacketConn, server ServerConfig, cred *krb5.Credential, ) (*Session, error)
NewSession creates a new Session attached to a given connection with server configuration and credential.
func NewSessionFull ¶
func NewSessionFull( conn net.PacketConn, server ServerConfig, cred *krb5.Credential, clock Clock, ) (*Session, error)
NewSessionFull creates a new Session attached to a given connection with server configuration and credential. This variant allows passing a custom clock for testing.
func (*Session) Credential ¶
func (s *Session) Credential() *krb5.Credential
Credential returns the credential for this session.
func (*Session) LocalAddr ¶
LocalAddr returns the local UDP address for the client when communicating with the Zephyr servers.
func (*Session) MakeUID ¶
MakeUID creates a new UID for a given time and this sessions local IP address.
func (*Session) Messages ¶
func (s *Session) Messages() <-chan MessageReaderResult
Messages returns the incoming messages from the session.
func (*Session) SendCancelSubscriptions ¶
SendCancelSubscriptions closes the session. This should be called before exit to release the port on the zephyrd. It returns the ACK from the server.
func (*Session) SendMessage ¶
SendMessage sends an authenticated message over the session, sharding into multiple notices as needed. It returns the ACK from the server if the message is ACKED.
func (*Session) SendMessageUnauth ¶
SendMessageUnauth sends an unauthenticated message over the session, sharding into multiple notices as needed. It returns the ACK from the server if the message is ACKED.
func (*Session) SendSubscribe ¶
SendSubscribe sends a subscription notice for a list of triples, along with any defaults configured on the server.
func (*Session) SendSubscribeNoDefaults ¶
func (s *Session) SendSubscribeNoDefaults( ctx *krb5.Context, subs []Subscription, ) (*Notice, error)
SendSubscribeNoDefaults sends a subscription notice for a list of triples. It returns the ACK from the server.
func (*Session) SendUnsubscribe ¶
SendUnsubscribe unsubscribes from a list of triples. It returns the ACK from the server.
type Subscription ¶
A Subscription represents a triple to subscribe to.
type UID ¶
type UID [12]byte
A UID is the identifier of a zephyr notice. It includes the sender's IP address and the send time.
type WindowedMap ¶
type WindowedMap struct {
// contains filtered or unexported fields
}
A WindowedMap is a map from UID to some value type where keys expire if not accessed for some time.
func NewWindowedMap ¶
func NewWindowedMap(lifetime time.Duration) *WindowedMap
NewWindowedMap creates a new WindowedMap with the specified lifetime for key entries.
func NewWindowedMapFull ¶
func NewWindowedMapFull(lifetime time.Duration, clock Clock) *WindowedMap
NewWindowedMapFull creates a new WindowedMap with the specified lifetime for key entries. It allows passing a custom Clock implementation for testing purposes.
func (*WindowedMap) ExpireOldEntries ¶
func (w *WindowedMap) ExpireOldEntries()
ExpireOldEntries removes entries from the windowed map which have since expired.
func (*WindowedMap) Len ¶
func (w *WindowedMap) Len() int
Len returns the number of entries in the windowed map. Note that this does not get updated for any entries that map have expired since the last lookup or modification.
func (*WindowedMap) Lookup ¶
func (w *WindowedMap) Lookup(uid UID) (interface{}, bool)
Lookup looks up the value for a given UID. The second return value is false if the key is not in the map. Looking up a UID updates the access time for that key.
func (*WindowedMap) Put ¶
func (w *WindowedMap) Put(uid UID, value interface{})
Put inserts a new value into the windowed map, overriding the existing value for UID if it already exists.
func (*WindowedMap) Remove ¶
func (w *WindowedMap) Remove(uid UID) (interface{}, bool)
Remove removes the entry for a given UID and returns the value associated with it. The second return value is false if the key is not in the map.