dtls

package module
v0.0.0-...-eaffae1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERVER_CERT_FILE = "certificates/server.pub.pem"
	SERVER_KEY_FILE  = "certificates/server.pem"
	CLIENT_CERT_FILE = "certificates/client.pub.pem"
	CLIENT_KEY_FILE  = "certificates/client.pem"
	CA_CERT_FILE     = "certificates/server.pub.pem"
)

Variables

This section is empty.

Functions

func GetCipherSuitesFormConfig

func GetCipherSuitesFormConfig(config []CipherSuitesType) (data []dtls.CipherSuiteID)

func GetClientAuthTypeFromConfig

func GetClientAuthTypeFromConfig(config ClientAuthType) (auth dtls.ClientAuthType)

func NewUdpDTLSClient

func NewUdpDTLSClient(ctx context.Context, addr *net.UDPAddr, certInfo CertificateInfo) (conn *dtls.Conn, err error)

func NewUdpListen

func NewUdpListen(ctx context.Context, addr *net.UDPAddr, config *Configuration, certInfo CertificateInfo) (listener net.Listener, err error)

func PathExists

func PathExists(path string) (bool, error)

Types

type CertificateInfo

type CertificateInfo struct {
	Cert       string
	PrivateKey string
	CaCert     string
}

type CipherSuitesType

type CipherSuitesType = string
const (
	// AES-128-CCM
	TLS_ECDHE_ECDSA_WITH_AES_128_CCM   CipherSuitesType = "TLS_ECDHE_ECDSA_WITH_AES_128_CCM"
	TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 CipherSuitesType = "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8"
	// AES-128-GCM-SHA256
	TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 CipherSuitesType = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
	TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256   CipherSuitesType = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
	// AES-256-CBC-SHA
	TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA CipherSuitesType = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
	TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA   CipherSuitesType = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
	// For PSK
	TLS_PSK_WITH_AES_128_CCM        CipherSuitesType = "TLS_PSK_WITH_AES_128_CCM"
	TLS_PSK_WITH_AES_128_CCM_8      CipherSuitesType = "TLS_PSK_WITH_AES_128_CCM_8"
	TLS_PSK_WITH_AES_128_GCM_SHA256 CipherSuitesType = "TLS_PSK_WITH_AES_128_GCM_SHA256"
	TLS_PSK_WITH_AES_128_CBC_SHA256 CipherSuitesType = "TLS_PSK_WITH_AES_128_CBC_SHA256"
)

type ClientAuthType

type ClientAuthType = string
const (
	ClientAuthType_NoClientCert               ClientAuthType = "NoClientCert"
	ClientAuthType_RequestClientCert          ClientAuthType = "RequestClientCert"
	ClientAuthType_RequireAnyClientCert       ClientAuthType = "RequireAnyClientCert"
	ClientAuthType_VerifyClientCertIfGiven    ClientAuthType = "VerifyClientCertIfGiven"
	ClientAuthType_RequireAndVerifyClientCert ClientAuthType = "RequireAndVerifyClientCert"
)

type Configuration

type Configuration struct {
	EnableN4_DTLS bool               `json:"enableN4_DTLS,omitempty" mapstructure:"enableN4_DTLS"`
	Psk           *PskConfig         `json:"psk,omitempty" mapstructure:"psk"`
	ClientAuth    ClientAuthType     `json:"clientAuth,omitempty" mapstructure:"clientAuth"`
	CipherSuites  []CipherSuitesType `json:"cipherSuites,omitempty" mapstructure:"cipherSuites"`
}

type PskConfig

type PskConfig struct {
	//Pre-defined password
	Password     string `json:"password,omitempty" mapstructure:"password"`
	IdentityHint string `json:"identityHint,omitempty" mapstructure:"identityHint"`
}

type UdpConnMap

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

func NewUdpConnMap

func NewUdpConnMap() *UdpConnMap

func (*UdpConnMap) Register

func (c *UdpConnMap) Register(conn net.Conn, ReceiveMsgFromPeerHandle func(conn net.Conn, msgLen uint32, msg []byte) error)

func (*UdpConnMap) SendMsgToAddr

func (c *UdpConnMap) SendMsgToAddr(addr string, msg []byte) (err error)

func (*UdpConnMap) UnRegister

func (c *UdpConnMap) UnRegister(addr string)

Jump to

Keyboard shortcuts

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