webrtc: validate ICE servers in configuration (#1798)
This commit is contained in:
parent
29f23c6dad
commit
71310c5eb0
|
@ -229,12 +229,20 @@ func (conf *Conf) Check() error {
|
||||||
if _, ok := conf.Protocols[Protocol(gortsplib.TransportUDP)]; ok {
|
if _, ok := conf.Protocols[Protocol(gortsplib.TransportUDP)]; ok {
|
||||||
return fmt.Errorf("strict encryption can't be used with the UDP transport protocol")
|
return fmt.Errorf("strict encryption can't be used with the UDP transport protocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := conf.Protocols[Protocol(gortsplib.TransportUDPMulticast)]; ok {
|
if _, ok := conf.Protocols[Protocol(gortsplib.TransportUDPMulticast)]; ok {
|
||||||
return fmt.Errorf("strict encryption can't be used with the UDP-multicast transport protocol")
|
return fmt.Errorf("strict encryption can't be used with the UDP-multicast transport protocol")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WebRTC
|
||||||
|
for _, server := range conf.WebRTCICEServers {
|
||||||
|
if !strings.HasPrefix(server, "stun:") &&
|
||||||
|
!strings.HasPrefix(server, "turn:") &&
|
||||||
|
!strings.HasPrefix(server, "turns:") {
|
||||||
|
return fmt.Errorf("invalid ICE server: '%s'", server)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do not add automatically "all", since user may want to
|
// do not add automatically "all", since user may want to
|
||||||
// initialize all paths through API or hot reloading.
|
// initialize all paths through API or hot reloading.
|
||||||
if conf.Paths == nil {
|
if conf.Paths == nil {
|
||||||
|
|
|
@ -214,6 +214,44 @@ func TestConfErrors(t *testing.T) {
|
||||||
`invalid: param`,
|
`invalid: param`,
|
||||||
"json: unknown field \"invalid\"",
|
"json: unknown field \"invalid\"",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"invalid readBufferCount",
|
||||||
|
"readBufferCount: 1001\n",
|
||||||
|
"'readBufferCount' must be a power of two",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid udpMaxPayloadSize",
|
||||||
|
"udpMaxPayloadSize: 5000\n",
|
||||||
|
"'udpMaxPayloadSize' must be less than 1472",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid externalAuthenticationURL 1",
|
||||||
|
"externalAuthenticationURL: testing\n",
|
||||||
|
"'externalAuthenticationURL' must be a HTTP URL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid externalAuthenticationURL 2",
|
||||||
|
"externalAuthenticationURL: http://myurl\n" +
|
||||||
|
"authMethods: [digest]\n",
|
||||||
|
"'externalAuthenticationURL' can't be used when 'digest' is in authMethods",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid strict encryption 1",
|
||||||
|
"encryption: strict\n" +
|
||||||
|
"protocols: [udp]\n",
|
||||||
|
"strict encryption can't be used with the UDP transport protocol",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid strict encryption 2",
|
||||||
|
"encryption: strict\n" +
|
||||||
|
"protocols: [multicast]\n",
|
||||||
|
"strict encryption can't be used with the UDP-multicast transport protocol",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid ICE server",
|
||||||
|
"webrtcICEServers: [testing]\n",
|
||||||
|
"invalid ICE server: 'testing'",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"non existent parameter 2",
|
"non existent parameter 2",
|
||||||
"paths:\n" +
|
"paths:\n" +
|
||||||
|
|
Loading…
Reference in New Issue