diable prflx over relay for firefox (#1226)
* Disable prflx over relay for firefox * remove ice lite change * solve comment * disable prflx for publisher too
This commit is contained in:
+13
-1
@@ -11,8 +11,20 @@ type ClientInfo struct {
|
|||||||
*livekit.ClientInfo
|
*livekit.ClientInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c ClientInfo) isFirefox() bool {
|
||||||
|
return c.ClientInfo != nil && strings.EqualFold(c.ClientInfo.Browser, "firefox")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ClientInfo) isSafari() bool {
|
||||||
|
return c.ClientInfo != nil && strings.EqualFold(c.ClientInfo.Browser, "safari")
|
||||||
|
}
|
||||||
|
|
||||||
func (c ClientInfo) SupportsAudioRED() bool {
|
func (c ClientInfo) SupportsAudioRED() bool {
|
||||||
return c.ClientInfo != nil && c.ClientInfo.Browser != "firefox" && c.ClientInfo.Browser != "safari"
|
return !c.isFirefox() && !c.isSafari()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ClientInfo) SupportPrflxOverRelay() bool {
|
||||||
|
return !c.isFirefox()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompareVersion compares two semver versions
|
// CompareVersion compares two semver versions
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type WebRTCConfig struct {
|
|||||||
TCPMuxListener *net.TCPListener
|
TCPMuxListener *net.TCPListener
|
||||||
Publisher DirectionConfig
|
Publisher DirectionConfig
|
||||||
Subscriber DirectionConfig
|
Subscriber DirectionConfig
|
||||||
|
ExternalIP string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReceiverConfig struct {
|
type ReceiverConfig struct {
|
||||||
@@ -83,6 +84,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
|||||||
s.SetIPFilter(filter)
|
s.SetIPFilter(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var confExternalIP string
|
||||||
// force it to the node IPs that the user has set
|
// force it to the node IPs that the user has set
|
||||||
if externalIP != "" && (conf.RTC.UseExternalIP || (conf.RTC.NodeIP != "" && !conf.RTC.NodeIPAutoGenerated)) {
|
if externalIP != "" && (conf.RTC.UseExternalIP || (conf.RTC.NodeIP != "" && !conf.RTC.NodeIPAutoGenerated)) {
|
||||||
if conf.RTC.UseExternalIP {
|
if conf.RTC.UseExternalIP {
|
||||||
@@ -92,6 +94,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
|||||||
}
|
}
|
||||||
logger.Debugw("using external IPs", "ips", ips)
|
logger.Debugw("using external IPs", "ips", ips)
|
||||||
s.SetNAT1To1IPs(ips, webrtc.ICECandidateTypeHost)
|
s.SetNAT1To1IPs(ips, webrtc.ICECandidateTypeHost)
|
||||||
|
confExternalIP = externalIP
|
||||||
} else {
|
} else {
|
||||||
s.SetNAT1To1IPs([]string{externalIP}, webrtc.ICECandidateTypeHost)
|
s.SetNAT1To1IPs([]string{externalIP}, webrtc.ICECandidateTypeHost)
|
||||||
}
|
}
|
||||||
@@ -237,6 +240,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
|||||||
TCPMuxListener: tcpListener,
|
TCPMuxListener: tcpListener,
|
||||||
Publisher: publisherConfig,
|
Publisher: publisherConfig,
|
||||||
Subscriber: subscriberConfig,
|
Subscriber: subscriberConfig,
|
||||||
|
ExternalIP: confExternalIP,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
|
|
||||||
se := params.Config.SettingEngine
|
se := params.Config.SettingEngine
|
||||||
se.DisableMediaEngineCopy(true)
|
se.DisableMediaEngineCopy(true)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Disable SRTP replay protection (https://datatracker.ietf.org/doc/html/rfc3711#page-15).
|
// Disable SRTP replay protection (https://datatracker.ietf.org/doc/html/rfc3711#page-15).
|
||||||
// Needed due to lack of RTX stream support in Pion.
|
// Needed due to lack of RTX stream support in Pion.
|
||||||
@@ -256,6 +257,11 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
se.SetDTLSRetransmissionInterval(dtlsRetransmissionInterval)
|
se.SetDTLSRetransmissionInterval(dtlsRetransmissionInterval)
|
||||||
se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval)
|
se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval)
|
||||||
|
|
||||||
|
// if client don't support prflx over relay, we should not expose private address to it, use single external ip as host candidate
|
||||||
|
if !params.ClientInfo.SupportPrflxOverRelay() && params.Config.ExternalIP != "" {
|
||||||
|
se.SetNAT1To1IPs([]string{params.Config.ExternalIP}, webrtc.ICECandidateTypeHost)
|
||||||
|
}
|
||||||
|
|
||||||
lf := serverlogger.NewLoggerFactory(params.Logger)
|
lf := serverlogger.NewLoggerFactory(params.Logger)
|
||||||
if lf != nil {
|
if lf != nil {
|
||||||
se.LoggerFactory = lf
|
se.LoggerFactory = lf
|
||||||
|
|||||||
Reference in New Issue
Block a user