(ext CandidateExtension)
| 653 | } |
| 654 | |
| 655 | func (c *candidateBase) AddExtension(ext CandidateExtension) error { |
| 656 | if ext.Key == "tcptype" { |
| 657 | tcpType := NewTCPType(ext.Value) |
| 658 | if tcpType == TCPTypeUnspecified { |
| 659 | return fmt.Errorf("%w: invalid or unsupported TCPtype %s", errParseTCPType, ext.Value) |
| 660 | } |
| 661 | |
| 662 | c.tcpType = tcpType |
| 663 | |
| 664 | return nil |
| 665 | } |
| 666 | |
| 667 | if ext.Key == "" { |
| 668 | return fmt.Errorf("%w: key is empty", errParseExtension) |
| 669 | } |
| 670 | |
| 671 | // per spec, Extensions aren't explicitly unique, we only set the first one. |
| 672 | // If the exteion is set multiple times. |
| 673 | for i := range c.extensions { |
| 674 | if c.extensions[i].Key == ext.Key { |
| 675 | c.extensions[i] = ext |
| 676 | |
| 677 | return nil |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | c.extensions = append(c.extensions, ext) |
| 682 | |
| 683 | return nil |
| 684 | } |
| 685 | |
| 686 | func (c *candidateBase) RemoveExtension(key string) (ok bool) { |
| 687 | if key == "tcptype" { |
nothing calls this directly
no test coverage detected