forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtlstransportstate.go
71 lines (62 loc) · 2.19 KB
/
dtlstransportstate.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package webrtc
// DTLSTransportState indicates the DTLS transport establishment state.
type DTLSTransportState int
const (
// DTLSTransportStateNew indicates that DTLS has not started negotiating
// yet.
DTLSTransportStateNew DTLSTransportState = iota + 1
// DTLSTransportStateConnecting indicates that DTLS is in the process of
// negotiating a secure connection and verifying the remote fingerprint.
DTLSTransportStateConnecting
// DTLSTransportStateConnected indicates that DTLS has completed
// negotiation of a secure connection and verified the remote fingerprint.
DTLSTransportStateConnected
// DTLSTransportStateClosed indicates that the transport has been closed
// intentionally as the result of receipt of a close_notify alert, or
// calling close().
DTLSTransportStateClosed
// DTLSTransportStateFailed indicates that the transport has failed as
// the result of an error (such as receipt of an error alert or failure to
// validate the remote fingerprint).
DTLSTransportStateFailed
)
// This is done this way because of a linter.
const (
dtlsTransportStateNewStr = "new"
dtlsTransportStateConnectingStr = "connecting"
dtlsTransportStateConnectedStr = "connected"
dtlsTransportStateClosedStr = "closed"
dtlsTransportStateFailedStr = "failed"
)
func newDTLSTransportState(raw string) DTLSTransportState {
switch raw {
case dtlsTransportStateNewStr:
return DTLSTransportStateNew
case dtlsTransportStateConnectingStr:
return DTLSTransportStateConnecting
case dtlsTransportStateConnectedStr:
return DTLSTransportStateConnected
case dtlsTransportStateClosedStr:
return DTLSTransportStateClosed
case dtlsTransportStateFailedStr:
return DTLSTransportStateFailed
default:
return DTLSTransportState(Unknown)
}
}
func (t DTLSTransportState) String() string {
switch t {
case DTLSTransportStateNew:
return dtlsTransportStateNewStr
case DTLSTransportStateConnecting:
return dtlsTransportStateConnectingStr
case DTLSTransportStateConnected:
return dtlsTransportStateConnectedStr
case DTLSTransportStateClosed:
return dtlsTransportStateClosedStr
case DTLSTransportStateFailed:
return dtlsTransportStateFailedStr
default:
return ErrUnknownType.Error()
}
}