Fix wg state check exit logic

This commit is contained in:
Zoltán Papp 2024-07-25 12:37:59 +02:00
parent efa0bbdf3d
commit b62ad97e59

View File

@ -63,10 +63,8 @@ func (w *WorkerRelay) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
srv := w.preferredRelayServer(currentRelayAddress, remoteOfferAnswer.RelaySrvAddress)
w.ctx, w.ctxCancel = context.WithCancel(w.parentCtx)
relayedConn, err := w.relayManager.OpenConn(srv, w.config.Key, w.disconnected)
if err != nil {
w.ctxCancel()
// todo handle all type errors
if errors.Is(err, relayClient.ErrConnAlreadyExists) {
w.log.Infof("do not need to reopen relay connection")
@ -76,6 +74,8 @@ func (w *WorkerRelay) OnNewOffer(remoteOfferAnswer *OfferAnswer) {
return
}
w.ctx, w.ctxCancel = context.WithCancel(w.parentCtx)
go w.wgStateCheck(relayedConn)
w.log.Debugf("Relay connection established with %s", srv)