/
types.go
40 lines (34 loc) · 926 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package config
import "strings"
// DataplaneModeType species the type of the STUN/TURN authentication mechanism used by STUNner
type DataplaneModeType int
const (
DataplaneModeManaged DataplaneModeType = iota // default
DataplaneModeLegacy
)
const (
dataplaneModeManagedStr = "managed"
dataplaneModeLegacyStr = "legacy"
)
// NewDataplaneModeType parses the dataplane mode specification.
func NewDataplaneMode(raw string) DataplaneModeType {
switch strings.ToLower(raw) {
case dataplaneModeManagedStr:
return DataplaneModeManaged
case dataplaneModeLegacyStr:
return DataplaneModeLegacy
default:
return DataplaneModeLegacy
}
}
// String returns a string representation for the dataplane mode.
func (a DataplaneModeType) String() string {
switch a {
case DataplaneModeManaged:
return dataplaneModeManagedStr
case DataplaneModeLegacy:
return dataplaneModeLegacyStr
default:
return "<unknown>"
}
}