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
This commit is contained in:
Sean DuBois
2021-12-15 15:51:34 -05:00
parent e9caba4e03
commit b897e71a59
3 changed files with 5 additions and 2 deletions
+1
View File
@@ -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 {
+3 -1
View File
@@ -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")
+1 -1
View File
@@ -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)
}