mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
restore API compatibility
This commit is contained in:
@@ -1286,7 +1286,7 @@ func TestClientPlayAutomaticProtocol(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, base.Describe, req.Method)
|
||||
|
||||
nonce, err := auth.GenerateNonce()
|
||||
nonce, err := auth.GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = conn.WriteResponse(&base.Response{
|
||||
@@ -1400,7 +1400,7 @@ func TestClientPlayAutomaticProtocol(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, base.Setup, req.Method)
|
||||
|
||||
nonce, err := auth.GenerateNonce()
|
||||
nonce, err := auth.GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = conn.WriteResponse(&base.Response{
|
||||
|
@@ -194,7 +194,7 @@ func TestClientAuth(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, base.Describe, req.Method)
|
||||
|
||||
nonce, err := auth.GenerateNonce()
|
||||
nonce, err := auth.GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = conn.WriteResponse(&base.Response{
|
||||
|
@@ -47,7 +47,7 @@ func TestAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(c1.name+"_"+conf, func(t *testing.T) {
|
||||
nonce, err := GenerateNonce()
|
||||
nonce, err := GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
se, err := NewSender(
|
||||
@@ -105,7 +105,7 @@ func TestAuthVLC(t *testing.T) {
|
||||
"rtsp://myhost/mypath/test?testing/trackID=0",
|
||||
},
|
||||
} {
|
||||
nonce, err := GenerateNonce()
|
||||
nonce, err := GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
se, err := NewSender(
|
||||
|
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/bluenviron/gortsplib/v3/pkg/url"
|
||||
)
|
||||
|
||||
// GenerateNonce generates a nonce that can be used in Validate().
|
||||
func GenerateNonce() (string, error) {
|
||||
// GenerateNonce2 generates a nonce that can be used in Validate().
|
||||
func GenerateNonce2() (string, error) {
|
||||
byts := make([]byte, 16)
|
||||
_, err := rand.Read(byts)
|
||||
if err != nil {
|
||||
@@ -21,6 +21,17 @@ func GenerateNonce() (string, error) {
|
||||
return hex.EncodeToString(byts), nil
|
||||
}
|
||||
|
||||
// GenerateNonce generates a nonce that can be used in Validate().
|
||||
//
|
||||
// Deprecated: use GenerateNonce2.
|
||||
func GenerateNonce() string {
|
||||
v, err := GenerateNonce2()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// GenerateWWWAuthenticate generates a WWW-Authenticate header.
|
||||
func GenerateWWWAuthenticate(methods []headers.AuthMethod, realm string, nonce string) base.HeaderValue {
|
||||
if methods == nil {
|
||||
|
@@ -64,10 +64,7 @@ func NewValidator(user string, pass string, methods []headers.AuthMethod) *Valid
|
||||
methods = []headers.AuthMethod{headers.AuthBasic}
|
||||
}
|
||||
|
||||
nonce, err := GenerateNonce()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
nonce := GenerateNonce()
|
||||
|
||||
return &Validator{
|
||||
user: user,
|
||||
|
@@ -1045,7 +1045,7 @@ func TestServerSessionTeardown(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServerAuth(t *testing.T) {
|
||||
nonce, err := auth.GenerateNonce()
|
||||
nonce, err := auth.GenerateNonce2()
|
||||
require.NoError(t, err)
|
||||
|
||||
s := &Server{
|
||||
|
Reference in New Issue
Block a user