Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSIPPort    int = 5060
	DefaultSIPPortTLS int = 5061
)
View Source
const (
	// After a call closes we keep its RTP port bound and draining so a freshly
	// allocated call can't inherit a port a peer is still sending stale media to.
	DefaultRTPDrainingIdleTimeout = 30 * time.Second // release once no packets arrive for this long
	DefaultRTPDrainingDuration    = 10 * time.Minute // hard cap on how long a port stays draining
)

Variables

View Source
var (
	DefaultRTPPortRange = rtcconfig.PortRange{Start: 10000, End: 20000}
)

Functions

func GetLocalIP

func GetLocalIP() (netip.Addr, error)

Types

type Config

type Config struct {
	Redis     *redis.RedisConfig `yaml:"redis"`      // required
	ApiKey    string             `yaml:"api_key"`    // required (env LIVEKIT_API_KEY)
	ApiSecret string             `yaml:"api_secret"` // required (env LIVEKIT_API_SECRET)
	WsUrl     string             `yaml:"ws_url"`     // required (env LIVEKIT_WS_URL)

	PSRPC rpc.PSRPCConfig `yaml:"psrpc,omitempty"`

	HealthPort           int                 `yaml:"health_port"`
	PrometheusPort       int                 `yaml:"prometheus_port"`
	PProfPort            int                 `yaml:"pprof_port"`
	SIPPort              int                 `yaml:"sip_port"`        // announced SIP signaling port
	SIPPortListen        int                 `yaml:"sip_port_listen"` // SIP signaling port to listen on
	SIPHostname          string              `yaml:"sip_hostname"`
	OutboundRouteHeaders []string            `yaml:"outbound_route_headers"` // Route headers prepended to outbound requests, e.g. "<sip:proxy:5060;transport=tcp;lr>"
	SIPRingingInterval   time.Duration       `yaml:"sip_ringing_interval"`   // from 1 sec up to 60 (default '1s')
	TCP                  *TCPConfig          `yaml:"tcp"`
	TLS                  *TLSConfig          `yaml:"tls"`
	RTPPort              rtcconfig.PortRange `yaml:"rtp_port"`
	Logging              logger.Config       `yaml:"logging"`
	ClusterID            string              `yaml:"cluster_id"` // cluster this instance belongs to
	MaxCpuUtilization    float64             `yaml:"max_cpu_utilization"`
	MaxActiveCalls       int                 `yaml:"max_active_calls"` // if set, used for affinity-based routing
	SIPTrunkIds          []string            `yaml:"sip_trunk_ids"`    // if set, only accept calls for these trunk IDs

	UseExternalIP bool   `yaml:"use_external_ip"`
	LocalNet      string `yaml:"local_net"` // local IP net to use, e.g. 192.168.0.0/24
	NAT1To1IP     string `yaml:"nat_1_to_1_ip"`
	ListenIP      string `yaml:"listen_ip"`

	UDPMaxPayload int `yaml:"udp_max_payload"`
	// if different from signaling IP
	MediaUseExternalIP bool   `yaml:"media_use_external_ip"`
	MediaNAT1To1IP     string `yaml:"media_nat_1_to_1_ip"`

	MediaTimeout        time.Duration `yaml:"media_timeout"`
	MediaTimeoutInitial time.Duration `yaml:"media_timeout_initial"`
	SymmetricRTP        bool          `yaml:"symmetric_rtp"`
	// RTPDrainingIdleTimeout / RTPDrainingDuration control how long a closed call's RTP
	// port is kept bound and draining before it can be reallocated. Set to a negative
	// value to disable. Zero uses the defaults.
	RTPDrainingIdleTimeout time.Duration   `yaml:"rtp_draining_idle_timeout"`
	RTPDrainingDuration    time.Duration   `yaml:"rtp_draining_duration"`
	IgnoreLocalAddrInSDP   bool            `yaml:"ignore_local_addr_in_sdp"` // enable symmetric RTP if local IP is specified in SDP
	Codecs                 map[string]bool `yaml:"codecs"`

	// HideInboundPort controls how SIP endpoint responds to unverified inbound requests.
	// Setting it to true makes SIP server silently drop INVITE requests if it gets a negative Auth or Dispatch response.
	// Doing so hides our SIP endpoint from (a low effort) port scanners.
	HideInboundPort bool `yaml:"hide_inbound_port"`
	// DisableRejectedInviteCache turns off the per-server cache that replays
	// a final INVITE rejection (keyed by Call-ID + From-tag) for retries
	// reusing the same identifiers.
	DisableRejectedInviteCache bool `yaml:"disable_rejected_invite_cache"`
	// AddRecordRoute forces SIP to add Record-Route headers to the responses.
	AddRecordRoute bool `yaml:"add_record_route"`

	// AudioDTMF forces SIP to generate audio DTMF tones in addition to digital.
	AudioDTMF              bool    `yaml:"audio_dtmf"`
	EnableJitterBuffer     bool    `yaml:"enable_jitter_buffer"`
	EnableJitterBufferProb float64 `yaml:"enable_jitter_buffer_prob"`

	// internal
	ServiceName string `yaml:"-"`
	NodeID      string // Do not provide, will be overwritten
	JaegerURL   string `yaml:"jaeger_url"` // for tracing
	// LoggerTee duplicates the log stream InitLogger builds. Set it before
	// Init; the zero value is a no-op.
	LoggerTee zaputil.Tee `yaml:"-"`

	// Experimental, these option might go away without notice.
	Experimental struct {
		// InboundWaitACK forces SIP to wait for an ACK to 200 OK before proceeding with the call.
		InboundWaitACK bool `yaml:"inbound_wait_ack"`
	} `yaml:"experimental"`
}

func NewConfig

func NewConfig(confString string) (*Config, error)

func (*Config) GetLoggerFields

func (c *Config) GetLoggerFields() logrus.Fields

GetLoggerFields is used with logrus

func (*Config) GetLoggerValues

func (c *Config) GetLoggerValues() []interface{}

GetLoggerValues is used with zap logger

func (*Config) Init

func (c *Config) Init() error

func (*Config) InitLogger

func (c *Config) InitLogger(values ...interface{}) error

type TCPConfig added in v1.3.0

type TCPConfig struct {
	DialPort rtcconfig.PortRange `yaml:"dial_port"`
}

type TLSCert

type TLSCert struct {
	CertFile string `yaml:"cert_file"`
	KeyFile  string `yaml:"key_file"`
}

type TLSConfig

type TLSConfig struct {
	Port       int       `yaml:"port"`        // announced SIP signaling port
	ListenPort int       `yaml:"port_listen"` // SIP signaling port to listen on
	Certs      []TLSCert `yaml:"certs"`
	KeyLog     string    `yaml:"key_log"`

	MinVersion string `yaml:"min_version"` // min TLS version, accepts: "tls1.0", "tls1.1", "tls1.2", "tls1.3"
	MaxVersion string `yaml:"max_version"` // max TLS version, accepts: "tls1.0", "tls1.1", "tls1.2", "tls1.3"

	// CipherSuites is an optional list of cipher suite names.
	// If not provided, Go's secure defaults are used.
	// Note: Only applies to TLS 1.0-1.2; TLS 1.3 cipher suites are not configurable.
	CipherSuites []string `yaml:"cipher_suites"`

	// WarnOnly disables enforcement of MinVersion, MaxVersion and CipherSuites.
	// Instead, a warning is logged for each handshake that negotiates a version or cipher suite outside of them.
	// Useful to check which connections would be affected before enforcing a stricter policy.
	WarnOnly bool `yaml:"warn_only"`

	// ALPNProtocols is an optional list of ALPN protocol names for TLS negotiation.
	// If not provided, defaults to ["sip"]. Set to an empty list to disable ALPN.
	// Some providers (e.g. Meta) reject the "sip" ALPN and require it to be disabled.
	ALPNProtocols []string `yaml:"alpn"`
}

func (*TLSConfig) ApplyPolicy added in v1.19.0

func (conf *TLSConfig) ApplyPolicy(log logger.Logger, c *tls.Config) error

ApplyPolicy applies MinVersion, MaxVersion and CipherSuites to c.

If WarnOnly is set, they are not applied. Instead, c keeps Go's defaults and logs a warning for each handshake that negotiates a version or cipher suite outside of them.

Jump to

Keyboard shortcuts

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