candidaterelatedaddress.go 747 B

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