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

Function readCandidateByteString

candidate_base.go:1020–1035  ·  view source on GitHub ↗

Read a byte-string token from the raw string As defined in RFC 4566 1*(%x01-09/%x0B-0C/%x0E-FF) ;any byte except NUL, CR, or LF we imply that extensions byte-string are UTF-8 encoded.

(raw string, start int)

Source from the content-addressed store, hash-verified

1018// As defined in RFC 4566 1*(%x01-09/%x0B-0C/%x0E-FF) ;any byte except NUL, CR, or LF
1019// we imply that extensions byte-string are UTF-8 encoded.
1020func readCandidateByteString(raw string, start int) (string, int, error) {
1021 for i, char := range raw[start:] {
1022 if char == 0x20 { // SP
1023 return raw[start : start+i], start + i + 1, nil
1024 }
1025
1026 // 1*(%x01-09/%x0B-0C/%x0E-FF)
1027 if (char < 0x01 || char > 0x09) &&
1028 (char < 0x0B || char > 0x0C) &&
1029 (char < 0x0E || char > 0xFF) {
1030 return "", 0, fmt.Errorf("invalid byte-string character: %c", char) //nolint: err113 // handled by caller
1031 }
1032 }
1033
1034 return raw[start:], len(raw), nil
1035}
1036
1037// Read and validate raddr and rport from the raw string
1038// [SP rel-addr] [SP rel-port]

Callers 1

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…