From b897e71a595026f18c5f1f515b04191019735291 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Wed, 15 Dec 2021 15:51:34 -0500 Subject: [PATCH] Expose ErrDetermineNetworkType Expose this error so pion/webrtc can handle gracefully. rfc8839#section-5.1 specifies that a WebRTC Agent MUST ignore any name/value pairs it doesn't understand. Relates to pion/webrtc#1949 --- candidate_test.go | 1 + errors.go | 4 +++- networktype.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/candidate_test.go b/candidate_test.go index 23745b0..5889e9e 100644 --- a/candidate_test.go +++ b/candidate_test.go @@ -307,6 +307,7 @@ func TestCandidateMarshal(t *testing.T) { {nil, "4207374051 1 udp INVALID 10.0.75.1 53634 typ host", true}, {nil, "4207374051 INVALID udp 2130706431 10.0.75.1 INVALID typ host", true}, {nil, "4207374051 1 udp 2130706431 10.0.75.1 53634 typ INVALID", true}, + {nil, "4207374051 1 INVALID 2130706431 10.0.75.1 53634 typ host", true}, } { actualCandidate, err := UnmarshalCandidate(test.marshaled) if test.expectError { diff --git a/errors.go b/errors.go index 03a6a8e..8ca9c2c 100644 --- a/errors.go +++ b/errors.go @@ -112,6 +112,9 @@ var ( // ErrUnknownCandidateTyp indicates that a candidate had a unknown type value. ErrUnknownCandidateTyp = errors.New("unknown candidate typ") + // ErrDetermineNetworkType indicates that the NetworkType was not able to be parsed + ErrDetermineNetworkType = errors.New("unable to determine networkType") + errSendPacket = errors.New("failed to send packet") errAttributeTooShortICECandidate = errors.New("attribute not long enough to be ICE candidate") errParseComponent = errors.New("could not parse component") @@ -124,7 +127,6 @@ var ( errReadingStreamingPacket = errors.New("error reading streaming packet") errWriting = errors.New("error writing to") errClosingConnection = errors.New("error closing connection") - errDetermineNetworkType = errors.New("unable to determine networkType") errMissingProtocolScheme = errors.New("missing protocol scheme") errTooManyColonsAddr = errors.New("too many colons in address") errRead = errors.New("unexpected error trying to read") diff --git a/networktype.go b/networktype.go index 462ff2d..9509101 100644 --- a/networktype.go +++ b/networktype.go @@ -126,5 +126,5 @@ func determineNetworkType(network string, ip net.IP) (NetworkType, error) { return NetworkTypeTCP6, nil } - return NetworkType(0), fmt.Errorf("%w from %s %s", errDetermineNetworkType, network, ip) + return NetworkType(0), fmt.Errorf("%w from %s %s", ErrDetermineNetworkType, network, ip) }