MCPcopy Create free account
hub / github.com/pion/ice / tryReadRelativeAddrs

Function tryReadRelativeAddrs

candidate_base.go:1041–1073  ·  view source on GitHub ↗

Read and validate raddr and rport from the raw string [SP rel-addr] [SP rel-port] defined in https://datatracker.ietf.org/doc/html/rfc5245#section-15.1 .

(raw string, start int)

Source from the content-addressed store, hash-verified

1039// defined in https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
1040// .
1041func tryReadRelativeAddrs(raw string, start int) (raddr string, rport, pos int, err error) {
1042 key, pos := readCandidateStringToken(raw, start)
1043
1044 if key != "raddr" {
1045 return "", 0, start, nil
1046 }
1047
1048 if pos >= len(raw) {
1049 return "", 0, 0, fmt.Errorf("%w: expected raddr value in %s", errParseRelatedAddr, raw)
1050 }
1051
1052 raddr, pos = readCandidateStringToken(raw, pos)
1053
1054 if pos >= len(raw) {
1055 return "", 0, 0, fmt.Errorf("%w: expected rport in %s", errParseRelatedAddr, raw)
1056 }
1057
1058 key, pos = readCandidateStringToken(raw, pos)
1059 if key != "rport" {
1060 return "", 0, 0, fmt.Errorf("%w: expected rport in %s", errParseRelatedAddr, raw)
1061 }
1062
1063 if pos >= len(raw) {
1064 return "", 0, 0, fmt.Errorf("%w: expected rport value in %s", errParseRelatedAddr, raw)
1065 }
1066
1067 rport, pos, err = readCandidatePort(raw, pos)
1068 if err != nil {
1069 return "", 0, 0, fmt.Errorf("%w: %v", errParseRelatedAddr, err) //nolint:errorlint // we wrap the error
1070 }
1071
1072 return raddr, rport, pos, nil
1073}
1074
1075// UnmarshalCandidateExtensions parses the candidate extensions from the raw string.
1076// *(SP extension-att-name SP extension-att-value)

Callers 1

UnmarshalCandidateFunction · 0.85

Calls 3

readCandidateStringTokenFunction · 0.85
readCandidatePortFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…