diff --git a/attribute_errorcode.go b/attribute_errorcode.go index 8403801..32562f6 100644 --- a/attribute_errorcode.go +++ b/attribute_errorcode.go @@ -10,6 +10,7 @@ const ( CodeUnauthorised ErrorCode = 401 CodeUnknownAttribute ErrorCode = 420 CodeStaleNonce ErrorCode = 428 + CodeRoleConflict ErrorCode = 478 CodeServerError ErrorCode = 500 ) @@ -28,6 +29,8 @@ func (c ErrorCode) Reason() string { return "Stale Nonce" case CodeServerError: return "Server Error" + case CodeRoleConflict: + return "Role conflict" default: return "Unknown Error" } diff --git a/attribute_errorcode_test.go b/attribute_errorcode_test.go index b905cdf..f42697d 100644 --- a/attribute_errorcode_test.go +++ b/attribute_errorcode_test.go @@ -9,6 +9,7 @@ func TestErrorCode_Reason(t *testing.T) { CodeUnauthorised, CodeUnknownAttribute, CodeStaleNonce, + CodeRoleConflict, CodeServerError, } for _, code := range codes { diff --git a/attributes.go b/attributes.go index c9a0712..fb7cac7 100644 --- a/attributes.go +++ b/attributes.go @@ -55,6 +55,27 @@ const ( AttrFingerprint AttrType = 0x8028 // FINGERPRINT ) +// Attributes from RFC 5245 ICE. +const ( + AttrPriority AttrType = 0x0024 // PRIORITY + AttrUseCandidate AttrType = 0x0025 // USE-CANDIDATE + AttrICEControlled AttrType = 0x8029 // ICE-CONTROLLED + AttrICEControlling AttrType = 0x802A // ICE-CONTROLLING +) + +// Attributes from RFC 5766 TURN. +const ( + AttrChannelNumber AttrType = 0x000C // CHANNEL-NUMBER + AttrLifetime AttrType = 0x000D // LIFETIME + AttrXORPeerAddress AttrType = 0x0012 // XOR-PEER-ADDRESS + AttrData AttrType = 0x0013 // DATA + AttrXORRelayedAddress AttrType = 0x0016 // XOR-RELAYED-ADDRESS + AttrEvenPort AttrType = 0x0018 // EVEN-PORT + AttrRequestedTransport AttrType = 0x0019 // REQUESTED-TRANSPORT + AttrDontFragment AttrType = 0x001A // DONT-FRAGMENT + AttrReservationToken AttrType = 0x0022 // RESERVATION-TOKEN +) + // Value returns uint16 representation of attribute type. func (t AttrType) Value() uint16 { return uint16(t) @@ -84,6 +105,32 @@ func (t AttrType) String() string { return "ALTERNATE-SERVER" case AttrFingerprint: return "FINGERPRINT" + case AttrPriority: + return "PRIORITY" + case AttrUseCandidate: + return "USE-CANDIDATE" + case AttrICEControlled: + return "ICE-CONTROLLED" + case AttrICEControlling: + return "ICE-CONTROLLING" + case AttrChannelNumber: + return "CHANNEL-NUMBER" + case AttrLifetime: + return "LIFETIME" + case AttrXORPeerAddress: + return "XOR-PEER-ADDRESS" + case AttrData: + return "DATA" + case AttrXORRelayedAddress: + return "XOR-RELAYED-ADDRESS" + case AttrEvenPort: + return "EVEN-PORT" + case AttrRequestedTransport: + return "REQUESTED-TRANSPORT" + case AttrDontFragment: + return "DONT-FRAGMENT" + case AttrReservationToken: + return "RESERVATION-TOKEN" default: // just return hex representation of unknown attribute type return "0x" + strconv.FormatUint(uint64(t), 16) diff --git a/stun.go b/stun.go index ac2371c..3fe66ee 100644 --- a/stun.go +++ b/stun.go @@ -432,13 +432,31 @@ type Method uint16 // Possible methods for STUN Message. const ( - MethodBinding Method = 0x01 // 0b000000000001 + MethodBinding Method = 0x001 + MethodAllocate Method = 0x003 + MethodRefresh Method = 0x004 + MethodSend Method = 0x006 + MethodData Method = 0x007 + MethodCreatePermission Method = 0x008 + MethodChannelBind Method = 0x009 ) func (m Method) String() string { switch m { case MethodBinding: return "binding" + case MethodAllocate: + return "allocate" + case MethodRefresh: + return "refresh" + case MethodSend: + return "send" + case MethodData: + return "data" + case MethodCreatePermission: + return "create permission" + case MethodChannelBind: + return "channel bind" default: return fmt.Sprintf("0x%s", strconv.FormatUint(uint64(m), 16)) }