Parse Candidate Extensions (RFC5245)

- Rewrote `UnmarshalCandidate` to better align with RFC5245.
- Added Candidate `Extensions` and `GetExtension`.
- Updated `Equal` and `Marshal` to accommodate these changes.
- New Type `CandidateExtension` to handle.
This commit is contained in:
Joe Turki
2025-01-15 21:38:13 -06:00
parent abdc0cadec
commit ab6e243686
4 changed files with 1242 additions and 79 deletions
+16
View File
@@ -52,12 +52,28 @@ type Candidate interface {
// candidate, which is useful for diagnostics and other purposes
RelatedAddress() *CandidateRelatedAddress
// Extensions returns a copy of all extension attributes associated with the ICECandidate.
// In the order of insertion, *(key value).
// Extension attributes are defined in RFC 5245, Section 15.1:
// https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
//.
Extensions() []CandidateExtension
// GetExtension returns the value of the extension attribute associated with the ICECandidate.
// Extension attributes are defined in RFC 5245, Section 15.1:
// https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
//.
GetExtension(key string) (value CandidateExtension, ok bool)
String() string
Type() CandidateType
TCPType() TCPType
Equal(other Candidate) bool
// DeepEqual same as Equal, But it also compares the candidate extensions.
DeepEqual(other Candidate) bool
Marshal() string
addr() net.Addr
+457 -78
View File
File diff suppressed because it is too large Load Diff
+767 -1
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -125,10 +125,12 @@ var (
errNotImplemented = errors.New("not implemented yet")
errNoUDPMuxAvailable = errors.New("no UDP mux is available")
errNoXorAddrMapping = errors.New("no address mapping")
errParseFoundation = errors.New("failed to parse foundation")
errParseComponent = errors.New("failed to parse component")
errParsePort = errors.New("failed to parse port")
errParsePriority = errors.New("failed to parse priority")
errParseRelatedAddr = errors.New("failed to parse related addresses")
errParseExtension = errors.New("failed to parse extension")
errParseTCPType = errors.New("failed to parse TCP type")
errRead = errors.New("failed to read")
errUDPMuxDisabled = errors.New("UDPMux is not enabled")