Get returns the value of the given key if it exists.
(key string)
| 632 | |
| 633 | // Get returns the value of the given key if it exists. |
| 634 | func (c *candidateBase) GetExtension(key string) (CandidateExtension, bool) { |
| 635 | extension := CandidateExtension{Key: key} |
| 636 | |
| 637 | for i := range c.extensions { |
| 638 | if c.extensions[i].Key == key { |
| 639 | extension.Value = c.extensions[i].Value |
| 640 | |
| 641 | return extension, true |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | // TCPType was manually set. |
| 646 | if key == "tcptype" && c.TCPType() != TCPTypeUnspecified { //nolint:goconst |
| 647 | extension.Value = c.TCPType().String() |
| 648 | |
| 649 | return extension, true |
| 650 | } |
| 651 | |
| 652 | return extension, false |
| 653 | } |
| 654 | |
| 655 | func (c *candidateBase) AddExtension(ext CandidateExtension) error { |
| 656 | if ext.Key == "tcptype" { |