summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/ice/v2/candidaterelatedaddress.go
blob: 18cf318317f117bda5f48661c060a8c826f37078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package ice

import "fmt"

// CandidateRelatedAddress convey transport addresses related to the
// candidate, useful for diagnostics and other purposes.
type CandidateRelatedAddress struct {
	Address string
	Port    int
}

// String makes CandidateRelatedAddress printable
func (c *CandidateRelatedAddress) String() string {
	if c == nil {
		return ""
	}

	return fmt.Sprintf(" related %s:%d", c.Address, c.Port)
}

// Equal allows comparing two CandidateRelatedAddresses.
// The CandidateRelatedAddress are allowed to be nil.
func (c *CandidateRelatedAddress) Equal(other *CandidateRelatedAddress) bool {
	if c == nil && other == nil {
		return true
	}
	return c != nil && other != nil &&
		c.Address == other.Address &&
		c.Port == other.Port
}