dtls

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	New        = 1
	Connecting = 2
	Connected  = 3
	Failed     = 4
	Closed     = 5

	Actpass = "actpass" // both fine.
	Passive = "passive" // server
	Active  = "active"  // client
)

Variables

This section is empty.

Functions

func NewConn

func NewConn(r io.Reader, w io.Writer) net.Conn

Types

type Certificate

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

func NewCertificate

func NewCertificate(key crypto.PrivateKey, tpl x509.Certificate) (*Certificate, error)

NewCertificate generates a new x509 compliant Certificate to be used by DTLS for encrypting data sent over the wire. This method differs from generateCertificate by allowing to specify a template x509.Certificate to be used in order to define certificate parameters.

func (*Certificate) Fingerprints

func (c *Certificate) Fingerprints() []Fingerprint

type CertificateGenerator

type CertificateGenerator interface {
	GenerateCertificate() *Certificate
}

func NewCertManager

func NewCertManager(unique bool) (CertificateGenerator, error)

NewCertManager if unique is true, we generate a cert for every call, otherwise we will use only one cert for all requests.

type Fingerprint

type Fingerprint struct {
	Algorithm string
	Value     string
}

type Option

type Option struct {
	Reader       io.Reader
	Writer       io.Writer
	Role         string
	OnState      func(int)
	Fingerprints *Fingerprint
	Certificate  *Certificate
}

type SrtpSession

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

func NewSrtpSession

func NewSrtpSession(transport *Transport) (*SrtpSession, error)

NewSrtpSession Start a new srtp session from dtls transport key.

func (*SrtpSession) DecryptSrtcp

func (s *SrtpSession) DecryptSrtcp(dst, data []byte) ([]byte, error)

DecryptSrtcp is not concurrent-safe, but it won't be called in concurrent.

func (*SrtpSession) DecryptSrtp

func (s *SrtpSession) DecryptSrtp(dst, data []byte) ([]byte, error)

DecryptSrtp is not concurrent-safe, but it won't be called in concurrent.

func (*SrtpSession) EncryptRtcp

func (s *SrtpSession) EncryptRtcp(dst, packet []byte) ([]byte, int, error)

EncryptRtcp is not concurrent-safe, but it won't be called in concurrent.

func (*SrtpSession) EncryptRtp

func (s *SrtpSession) EncryptRtp(dst, packet []byte) ([]byte, int, error)

EncryptRtp is not concurrent-safe, but it won't be called in concurrent.

type Transport

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

func NewDtlsTransport

func NewDtlsTransport(option Option) *Transport

normally if chrome generate offer it will be actpass if they are both fine, we prefer client, we could send client hello asap, zero rtt. but the problem is, without ice completed, the dtls client could fail, not verify could it be wait. client could fail, but fast.

func (*Transport) DtlsConn

func (t *Transport) DtlsConn() *dtls.Conn

func (*Transport) GetLocalFingerprints

func (t *Transport) GetLocalFingerprints() []Fingerprint

func (*Transport) GetState

func (t *Transport) GetState() int

func (*Transport) Role

func (t *Transport) Role() string

func (*Transport) TryRun

func (t *Transport) TryRun()

it could be called more than once, that is the reason try. but clearly we did not handle it yet.

Jump to

Keyboard shortcuts

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