Documentation
¶
Index ¶
- func GenerateCredentials(secret, namespace string, ttl time.Duration) (username, password string)
- func GeneratePassword(secret, username string) string
- func GenerateSelfSignedCert(certPath, keyPath, publicIP string) error
- func ValidateCredentials(secret, username, password, expectedNamespace string) bool
- type Config
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCredentials ¶
GenerateCredentials creates time-limited HMAC-SHA1 TURN credentials. Returns username and password suitable for WebRTC ICE server configuration.
func GeneratePassword ¶
GeneratePassword computes the HMAC-SHA1 password for a TURN username.
func GenerateSelfSignedCert ¶
GenerateSelfSignedCert generates a self-signed TLS certificate for TURNS. The certificate is valid for 1 year and includes the public IP as a SAN.
func ValidateCredentials ¶
ValidateCredentials checks if TURN credentials are valid and not expired.
Types ¶
type Config ¶
type Config struct {
// ListenAddr is the address to bind the TURN listener (e.g., "0.0.0.0:3478")
ListenAddr string `yaml:"listen_addr"`
// TURNSListenAddr is the address for TURNS (TURN over TLS on TCP, e.g., "0.0.0.0:5349")
TURNSListenAddr string `yaml:"turns_listen_addr"`
// TLSCertPath is the path to the TLS certificate PEM file (for TURNS)
TLSCertPath string `yaml:"tls_cert_path"`
// TLSKeyPath is the path to the TLS private key PEM file (for TURNS)
TLSKeyPath string `yaml:"tls_key_path"`
// PublicIP is the public IP address of this node, advertised in TURN allocations
PublicIP string `yaml:"public_ip"`
// Realm is the TURN realm (typically the base domain)
Realm string `yaml:"realm"`
// AuthSecret is the HMAC-SHA1 shared secret for credential validation
AuthSecret string `yaml:"auth_secret"`
// RelayPortStart is the beginning of the UDP relay port range
RelayPortStart int `yaml:"relay_port_start"`
// RelayPortEnd is the end of the UDP relay port range
RelayPortEnd int `yaml:"relay_port_end"`
// Namespace this TURN instance belongs to
Namespace string `yaml:"namespace"`
}
Config holds configuration for the TURN server
Click to show internal directories.
Click to hide internal directories.