From bce6de3c843434be73b1c07688ad9ea40c10fcf5 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 16 Oct 2022 09:54:06 +0200 Subject: [PATCH] Implement copy() for CandidateRelay Relay candidates have an additional field "relayProtocol" which is not marshaled and hence not copied by the candidateBase's copy() method. This change is required to properly expose the relay protocol for via the agents GetSelectedCandidatePair() function as it internally copies the candidates. --- candidate_relay.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/candidate_relay.go b/candidate_relay.go index 3d0be31..864e884 100644 --- a/candidate_relay.go +++ b/candidate_relay.go @@ -79,3 +79,16 @@ func (c *CandidateRelay) close() error { } return err } + +func (c *CandidateRelay) copy() (Candidate, error) { + cc, err := c.candidateBase.copy() + if err != nil { + return nil, err + } + + if ccr, ok := cc.(*CandidateRelay); ok { + ccr.relayProtocol = c.relayProtocol + } + + return cc, nil +}