godave

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

Go Reference Go Report Go Version License GoDave Version DisGo Discord

discord gopher

GoDave

GoDave is a library that provides Go bindings for libdave and provides a generic DAVE interface allowing for different implementations in the future.

Summary

  1. Libdave Installation
    1. Windows Installation
    2. Installing manually
  2. Example Usage
  3. License

Libdave Installation

This library uses CGO and dynamic linking to use libdave.

We provide helpful scripts under scripts/ to allow you to download pre-built binaries of build them yourself, depending on your needs. Please audit them before executing!

[!NOTE] Due to the nature of this project, it might be necessary to re-install libdave when updating to a new GoDave version. The version that require this may be indicated with a minor bump (for reference: mayor.minor.patch).

You can see what version is required by checking this file

Linux/MacOS/WSL instructions

Open a terminal and execute the following commands:

# Set CC/CXX variables to change the compiler used (ie, for clang
#export CC=/usr/bin/clang CXX=/usr/bin/clang

./libdave_install.sh v1.1.0
MUSL Linux

If you want to build a MUSL version of libdave, you can execute the following commands:

export VCPKG_FORCE_SYSTEM_BINARIES=1
export CC=/usr/bin/gcc CXX=/usr/bin/g++
export CXXFLAGS="-Wno-error=maybe-uninitialized"

# Install necessary packages
apk add build-base cmake ninja zip unzip curl git pkgconfig perl nams go

# FORCE_BUILD=1 as Discord do not provide pre-built binaries
FORCE_BUILD=1 ./libdave_install.sh v1.1.0
Windows instructions

Open Powershell and execute the following commands:

Set-ExecutionPolicy RemoteSigned –Scope Process
.\libdave_install.ps1 v1.1.0

Example Usage

For an example of how to use GoDave, please see here

License

Distributed under the License. See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks interface {
	// SendMLSKeyPackage sends a MLS Key Package to the voice gateway.
	SendMLSKeyPackage(mlsKeyPackage []byte) error
	// SendMLSCommitWelcome sends a MLS Commit Welcome to the voice gateway.
	SendMLSCommitWelcome(mlsCommitWelcome []byte) error
	// SendReadyForTransition notifies the voice gateway that the client is ready for the transition.
	SendReadyForTransition(transitionID uint16) error
	// SendInvalidCommitWelcome notifies the voice gateway that the commit welcome is invalid.
	SendInvalidCommitWelcome(transitionID uint16) error
}

Callbacks represents the callbacks used by a DAVE session to send messages back to the voice gateway.

type ChannelID

type ChannelID uint64

type Codec

type Codec int

Codec represents an audio codec used in the DAVE protocol.

const (
	// CodecOpus represents the OPUS audio codec.
	CodecOpus Codec = 1
)

type Session

type Session interface {
	// MaxSupportedProtocolVersion returns the maximum supported DAVE version for this session.
	MaxSupportedProtocolVersion() int

	// SetChannelID sets the channel ID for this session.
	SetChannelID(channelID ChannelID)

	// AssignSsrcToCodec maps a given SSRC to a specific Codec.
	AssignSsrcToCodec(ssrc uint32, codec Codec)

	// MaxEncryptedFrameSize returns the maximum size of an encrypted OPUS frame given the frame size.
	MaxEncryptedFrameSize(frameSize int) int

	// Encrypt encrypts an OPUS frame.
	Encrypt(ssrc uint32, frame []byte, encryptedFrame []byte) (int, error)

	// MaxDecryptedFrameSize returns the maximum size of a decrypted OPUS frame given the frame size.
	MaxDecryptedFrameSize(userID UserID, frameSize int) int

	// Decrypt decrypts an OPUS frame.
	Decrypt(userID UserID, frame []byte, decryptedFrame []byte) (int, error)

	// AddUser adds a user to the MLS group.
	AddUser(userID UserID)

	// RemoveUser removes a use from the MLS group.
	RemoveUser(userID UserID)

	// OnSelectProtocolAck is to be called when SELECT_PROTOCOL_ACK (4) is received.
	OnSelectProtocolAck(protocolVersion uint16)

	// OnDavePrepareTransition is to be called when DAVE_PROTOCOL_PREPARE_TRANSITION (21) is received.
	OnDavePrepareTransition(transitionID uint16, protocolVersion uint16)

	// OnDaveExecuteTransition is to be called when DAVE_PROTOCOL_EXECUTE_TRANSITION (22) is received.
	OnDaveExecuteTransition(protocolVersion uint16)

	// OnDavePrepareEpoch is to be called when DAVE_PROTOCOL_PREPARE_EPOCH (24) is received.
	OnDavePrepareEpoch(epoch int, protocolVersion uint16)

	// OnDaveMLSExternalSenderPackage is to be called when DAVE_MLS_EXTERNAL_SENDER_PACKAGE (25) is received.
	OnDaveMLSExternalSenderPackage(externalSenderPackage []byte)

	// OnDaveMLSProposals is to be called when DAVE_MLS_PROPOSALS (27) is received.
	OnDaveMLSProposals(proposals []byte)

	// OnDaveMLSPrepareCommitTransition is to be called when DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION (29) is received.
	OnDaveMLSPrepareCommitTransition(transitionID uint16, commitMessage []byte)

	// OnDaveMLSWelcome is to be called when DAVE_MLS_WELCOME (30) is received.
	OnDaveMLSWelcome(transitionID uint16, welcomeMessage []byte)
}

Session is an interface representing a DAVE session. Implementations of this interface should handle encryption, decryption, and DAVE protocol events.

func NewNoopSession

func NewNoopSession(logger *slog.Logger, _ UserID, _ Callbacks) Session

type SessionCreateFunc

type SessionCreateFunc func(logger *slog.Logger, userID UserID, callbacks Callbacks) Session

SessionCreateFunc is an agnostic function type for creating DAVE sessions.

type UserID

type UserID string

Directories

Path Synopsis
golibdave module
libdave module

Jump to

Keyboard shortcuts

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