candidaterelatedaddress.go 849 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package ice
  4. import "fmt"
  5. // CandidateRelatedAddress convey transport addresses related to the
  6. // candidate, useful for diagnostics and other purposes.
  7. type CandidateRelatedAddress struct {
  8. Address string
  9. Port int
  10. }
  11. // String makes CandidateRelatedAddress printable
  12. func (c *CandidateRelatedAddress) String() string {
  13. if c == nil {
  14. return ""
  15. }
  16. return fmt.Sprintf(" related %s:%d", c.Address, c.Port)
  17. }
  18. // Equal allows comparing two CandidateRelatedAddresses.
  19. // The CandidateRelatedAddress are allowed to be nil.
  20. func (c *CandidateRelatedAddress) Equal(other *CandidateRelatedAddress) bool {
  21. if c == nil && other == nil {
  22. return true
  23. }
  24. return c != nil && other != nil &&
  25. c.Address == other.Address &&
  26. c.Port == other.Port
  27. }