diff --git a/internal/conf/authmethod.go b/internal/conf/authmethod.go index 5866fcbc..6c0d2257 100644 --- a/internal/conf/authmethod.go +++ b/internal/conf/authmethod.go @@ -3,6 +3,7 @@ package conf import ( "encoding/json" "fmt" + "sort" "strings" "github.com/aler9/gortsplib/pkg/headers" @@ -13,18 +14,20 @@ type AuthMethods []headers.AuthMethod // MarshalJSON marshals a AuthMethods into JSON. func (d AuthMethods) MarshalJSON() ([]byte, error) { - var out []string + out := make([]string, len(d)) - for _, v := range d { + for i, v := range d { switch v { case headers.AuthBasic: - out = append(out, "basic") + out[i] = "basic" default: - out = append(out, "digest") + out[i] = "digest" } } + sort.Strings(out) + return json.Marshal(out) } diff --git a/internal/conf/ipsornets.go b/internal/conf/ipsornets.go index cf5c5799..81c7df53 100644 --- a/internal/conf/ipsornets.go +++ b/internal/conf/ipsornets.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net" + "sort" "strings" ) @@ -18,6 +19,8 @@ func (d IPsOrNets) MarshalJSON() ([]byte, error) { out[i] = v.(fmt.Stringer).String() } + sort.Strings(out) + return json.Marshal(out) } diff --git a/internal/conf/logdestination.go b/internal/conf/logdestination.go index d324ef0a..5715d667 100644 --- a/internal/conf/logdestination.go +++ b/internal/conf/logdestination.go @@ -3,6 +3,7 @@ package conf import ( "encoding/json" "fmt" + "sort" "strings" "github.com/aler9/rtsp-simple-server/internal/logger" @@ -34,6 +35,8 @@ func (d LogDestinations) MarshalJSON() ([]byte, error) { i++ } + sort.Strings(out) + return json.Marshal(out) } diff --git a/internal/conf/protocol.go b/internal/conf/protocol.go index c09df72c..0843b011 100644 --- a/internal/conf/protocol.go +++ b/internal/conf/protocol.go @@ -3,6 +3,7 @@ package conf import ( "encoding/json" "fmt" + "sort" "strings" ) @@ -42,6 +43,8 @@ func (d Protocols) MarshalJSON() ([]byte, error) { i++ } + sort.Strings(out) + return json.Marshal(out) }