mirror of
https://github.com/DeBrosOfficial/orama.git
synced 2026-03-17 09:16:57 +00:00
- Updated version in Makefile to 0.112.2. - Enhanced SFU server error handling to ignore http.ErrServerClosed. - Added TURNS (TURN over TLS) configuration options in TURN server and related components. - Updated firewall rules to include TURNS ports and modified related tests. - Implemented self-signed certificate generation for TURNS. - Adjusted TURN server to support both UDP and TCP listeners. - Updated WebRTC and SFU components to accommodate new TURNS configurations.
77 lines
2.4 KiB
Go
77 lines
2.4 KiB
Go
package turn
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
// Config holds configuration for the TURN server
|
|
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"`
|
|
}
|
|
|
|
// Validate checks the TURN configuration for errors
|
|
func (c *Config) Validate() []error {
|
|
var errs []error
|
|
|
|
if c.ListenAddr == "" {
|
|
errs = append(errs, fmt.Errorf("turn.listen_addr: must not be empty"))
|
|
}
|
|
|
|
if c.PublicIP == "" {
|
|
errs = append(errs, fmt.Errorf("turn.public_ip: must not be empty"))
|
|
} else if ip := net.ParseIP(c.PublicIP); ip == nil {
|
|
errs = append(errs, fmt.Errorf("turn.public_ip: %q is not a valid IP address", c.PublicIP))
|
|
}
|
|
|
|
if c.Realm == "" {
|
|
errs = append(errs, fmt.Errorf("turn.realm: must not be empty"))
|
|
}
|
|
|
|
if c.AuthSecret == "" {
|
|
errs = append(errs, fmt.Errorf("turn.auth_secret: must not be empty"))
|
|
}
|
|
|
|
if c.RelayPortStart <= 0 || c.RelayPortEnd <= 0 {
|
|
errs = append(errs, fmt.Errorf("turn.relay_port_range: start and end must be positive"))
|
|
} else if c.RelayPortEnd <= c.RelayPortStart {
|
|
errs = append(errs, fmt.Errorf("turn.relay_port_range: end (%d) must be greater than start (%d)", c.RelayPortEnd, c.RelayPortStart))
|
|
} else if c.RelayPortEnd-c.RelayPortStart < 100 {
|
|
errs = append(errs, fmt.Errorf("turn.relay_port_range: range must be at least 100 ports (got %d)", c.RelayPortEnd-c.RelayPortStart))
|
|
}
|
|
|
|
if c.Namespace == "" {
|
|
errs = append(errs, fmt.Errorf("turn.namespace: must not be empty"))
|
|
}
|
|
|
|
return errs
|
|
}
|