-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry.go
179 lines (171 loc) · 7.83 KB
/
registry.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package stun
// Do not edit. This file is generated by 'go generate gen.go'
// This file provides STUN parameters managed by the Internet Assigned Numbers Authority (IANA).
// Session Traversal Utilities for NAT (STUN) Parameters, Updated: 2016-11-14.
// STUN methods.
const (
MethodBinding uint16 = 0x001 // RFC 5389
MethodSharedSecret uint16 = 0x002
MethodAllocate uint16 = 0x003 // RFC 5766
MethodRefresh uint16 = 0x004
MethodSend uint16 = 0x006
MethodData uint16 = 0x007
MethodCreatePermission uint16 = 0x008
MethodChannelBind uint16 = 0x009
MethodConnect uint16 = 0x00a // RFC 6062
MethodConnectionBind uint16 = 0x00b
MethodConnectionAttempt uint16 = 0x00c
)
// STUN method names.
var methodNames = map[uint16]string{
MethodBinding: "Binding",
MethodSharedSecret: "SharedSecret",
MethodAllocate: "Allocate",
MethodRefresh: "Refresh",
MethodSend: "Send",
MethodData: "Data",
MethodCreatePermission: "CreatePermission",
MethodChannelBind: "ChannelBind",
MethodConnect: "Connect",
MethodConnectionBind: "ConnectionBind",
MethodConnectionAttempt: "ConnectionAttempt",
}
// STUN attributes.
const (
AttrMappedAddress uint16 = 0x0001 // RFC 5389
AttrChangeRequest uint16 = 0x0003 // RFC 5780
AttrUsername uint16 = 0x0006 // RFC 5389
AttrMessageIntegrity uint16 = 0x0008
AttrErrorCode uint16 = 0x0009
AttrUnknownAttributes uint16 = 0x000a
AttrChannelNumber uint16 = 0x000c // RFC 5766
AttrLifetime uint16 = 0x000d
AttrXorPeerAddress uint16 = 0x0012
AttrData uint16 = 0x0013
AttrRealm uint16 = 0x0014 // RFC 5389
AttrNonce uint16 = 0x0015
AttrXorRelayedAddress uint16 = 0x0016 // RFC 5766
AttrRequestedAddressFamily uint16 = 0x0017 // RFC 6156
AttrEvenPort uint16 = 0x0018 // RFC 5766
AttrRequestedTransport uint16 = 0x0019
AttrDontFragment uint16 = 0x001a
AttrAccessToken uint16 = 0x001b // RFC 7635
AttrXorMappedAddress uint16 = 0x0020 // RFC 5389
AttrReservationToken uint16 = 0x0022 // RFC 5766
AttrPriority uint16 = 0x0024 // RFC 5245
AttrUseCandidate uint16 = 0x0025
AttrPadding uint16 = 0x0026 // RFC 5780
AttrResponsePort uint16 = 0x0027
AttrConnectionID uint16 = 0x002a // RFC 6062
AttrSoftware uint16 = 0x8022 // RFC 5389
AttrAlternateServer uint16 = 0x8023
AttrTransactionTransmitCounter uint16 = 0x8025 // RFC 7982
AttrCacheTimeout uint16 = 0x8027 // RFC 5780
AttrFingerprint uint16 = 0x8028 // RFC 5389
AttrIceControlled uint16 = 0x8029 // RFC 5245
AttrIceControlling uint16 = 0x802a
AttrResponseOrigin uint16 = 0x802b // RFC 5780
AttrOtherAddress uint16 = 0x802c
AttrEcnCheck uint16 = 0x802d // RFC 6679
AttrThirdPartyAuthorization uint16 = 0x802e // RFC 7635
AttrMobilityTicket uint16 = 0x8030 // RFC 8016
)
// Deprecated: For backwards compatibility only.
const (
AttrResponseAddress uint16 = 0x0002
AttrSourceAddress uint16 = 0x0004
AttrChangedAddress uint16 = 0x0005
AttrPassword uint16 = 0x0007
AttrReflectedFrom uint16 = 0x000b
AttrBandwidth uint16 = 0x0010
AttrTimerVal uint16 = 0x0021
)
// STUN attribute names.
var attrNames = map[uint16]string{
AttrMappedAddress: "MAPPED-ADDRESS",
AttrResponseAddress: "RESPONSE-ADDRESS",
AttrChangeRequest: "CHANGE-REQUEST",
AttrSourceAddress: "SOURCE-ADDRESS",
AttrChangedAddress: "CHANGED-ADDRESS",
AttrUsername: "USERNAME",
AttrPassword: "PASSWORD",
AttrMessageIntegrity: "MESSAGE-INTEGRITY",
AttrErrorCode: "ERROR-CODE",
AttrUnknownAttributes: "UNKNOWN-ATTRIBUTES",
AttrReflectedFrom: "REFLECTED-FROM",
AttrChannelNumber: "CHANNEL-NUMBER",
AttrLifetime: "LIFETIME",
AttrBandwidth: "BANDWIDTH",
AttrXorPeerAddress: "XOR-PEER-ADDRESS",
AttrData: "DATA",
AttrRealm: "REALM",
AttrNonce: "NONCE",
AttrXorRelayedAddress: "XOR-RELAYED-ADDRESS",
AttrRequestedAddressFamily: "REQUESTED-ADDRESS-FAMILY",
AttrEvenPort: "EVEN-PORT",
AttrRequestedTransport: "REQUESTED-TRANSPORT",
AttrDontFragment: "DONT-FRAGMENT",
AttrAccessToken: "ACCESS-TOKEN",
AttrXorMappedAddress: "XOR-MAPPED-ADDRESS",
AttrTimerVal: "TIMER-VAL",
AttrReservationToken: "RESERVATION-TOKEN",
AttrPriority: "PRIORITY",
AttrUseCandidate: "USE-CANDIDATE",
AttrPadding: "PADDING",
AttrResponsePort: "RESPONSE-PORT",
AttrConnectionID: "CONNECTION-ID",
AttrSoftware: "SOFTWARE",
AttrAlternateServer: "ALTERNATE-SERVER",
AttrTransactionTransmitCounter: "TRANSACTION-TRANSMIT-COUNTER",
AttrCacheTimeout: "CACHE-TIMEOUT",
AttrFingerprint: "FINGERPRINT",
AttrIceControlled: "ICE-CONTROLLED",
AttrIceControlling: "ICE-CONTROLLING",
AttrResponseOrigin: "RESPONSE-ORIGIN",
AttrOtherAddress: "OTHER-ADDRESS",
AttrEcnCheck: "ECN-CHECK",
AttrThirdPartyAuthorization: "THIRD-PARTY-AUTHORIZATION",
AttrMobilityTicket: "MOBILITY-TICKET",
}
// STUN error codes.
const (
CodeTryAlternate int = 300 // RFC 5389
CodeBadRequest int = 400
CodeUnauthorized int = 401
CodeForbidden int = 403 // RFC 5766
CodeMobilityForbidden int = 405 // RFC 8016
CodeUnknownAttribute int = 420 // RFC 5389
CodeAllocationMismatch int = 437 // RFC 5766
CodeStaleNonce int = 438 // RFC 5389
CodeAddressFamilyNotSupported int = 440 // RFC 6156
CodeWrongCredentials int = 441 // RFC 5766
CodeUnsupportedTransportProtocol int = 442
CodePeerAddressFamilyMismatch int = 443 // RFC 6156
CodeConnectionAlreadyExists int = 446 // RFC 6062
CodeConnectionTimeoutOrFailure int = 447
CodeAllocationQuotaReached int = 486 // RFC 5766
CodeRoleConflict int = 487 // RFC 5245
CodeServerError int = 500 // RFC 5389
CodeInsufficientCapacity int = 508 // RFC 5766
)
// STUN error texts.
var errorText = map[int]string{
CodeTryAlternate: "Try Alternate",
CodeBadRequest: "Bad Request",
CodeUnauthorized: "Unauthorized",
CodeForbidden: "Forbidden",
CodeMobilityForbidden: "Mobility Forbidden",
CodeUnknownAttribute: "Unknown Attribute",
CodeAllocationMismatch: "Allocation Mismatch",
CodeStaleNonce: "Stale Nonce",
CodeAddressFamilyNotSupported: "Address Family not Supported",
CodeWrongCredentials: "Wrong Credentials",
CodeUnsupportedTransportProtocol: "Unsupported Transport Protocol",
CodePeerAddressFamilyMismatch: "Peer Address Family Mismatch",
CodeConnectionAlreadyExists: "Connection Already Exists",
CodeConnectionTimeoutOrFailure: "Connection Timeout or Failure",
CodeAllocationQuotaReached: "Allocation Quota Reached",
CodeRoleConflict: "Role Conflict",
CodeServerError: "Server Error",
CodeInsufficientCapacity: "Insufficient Capacity",
}