mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-08 22:03:58 +01:00
fix relay migration panic (#1403)
This commit is contained in:
parent
04d7a8ccba
commit
8c29b15c6d
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -227,21 +228,25 @@ func (n *connectionManager) migrateRelayUsed(oldhostinfo, newhostinfo *HostInfo)
|
|||||||
var relayFrom netip.Addr
|
var relayFrom netip.Addr
|
||||||
var relayTo netip.Addr
|
var relayTo netip.Addr
|
||||||
switch {
|
switch {
|
||||||
case ok && existing.State == Established:
|
case ok:
|
||||||
// This relay already exists in newhostinfo, then do nothing.
|
switch existing.State {
|
||||||
continue
|
case Established, PeerRequested, Disestablished:
|
||||||
case ok && existing.State == Requested:
|
// This relay already exists in newhostinfo, then do nothing.
|
||||||
// The relay exists in a Requested state; re-send the request
|
continue
|
||||||
index = existing.LocalIndex
|
case Requested:
|
||||||
switch r.Type {
|
// The relayed connection exists in a Requested state; re-send the request
|
||||||
case TerminalType:
|
index = existing.LocalIndex
|
||||||
relayFrom = n.intf.myVpnNet.Addr()
|
switch r.Type {
|
||||||
relayTo = existing.PeerIp
|
case TerminalType:
|
||||||
case ForwardingType:
|
relayFrom = n.intf.myVpnNet.Addr()
|
||||||
relayFrom = existing.PeerIp
|
relayTo = existing.PeerIp
|
||||||
relayTo = newhostinfo.vpnIp
|
case ForwardingType:
|
||||||
default:
|
relayFrom = existing.PeerIp
|
||||||
// should never happen
|
relayTo = newhostinfo.vpnIp
|
||||||
|
default:
|
||||||
|
// should never happen
|
||||||
|
panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case !ok:
|
case !ok:
|
||||||
n.relayUsedLock.RLock()
|
n.relayUsedLock.RLock()
|
||||||
@ -267,6 +272,7 @@ func (n *connectionManager) migrateRelayUsed(oldhostinfo, newhostinfo *HostInfo)
|
|||||||
relayTo = newhostinfo.vpnIp
|
relayTo = newhostinfo.vpnIp
|
||||||
default:
|
default:
|
||||||
// should never happen
|
// should never happen
|
||||||
|
panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user