mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
wgengine/magicsock: fix crash in Send when Endpoint isn't an AddrSet
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
868cfae84f
commit
7a3b91390b
@ -417,7 +417,16 @@ func appendDests(dsts []*net.UDPAddr, as *AddrSet, b []byte) (_ []*net.UDPAddr,
|
|||||||
var errNoDestinations = errors.New("magicsock: no destinations")
|
var errNoDestinations = errors.New("magicsock: no destinations")
|
||||||
|
|
||||||
func (c *Conn) Send(b []byte, ep conn.Endpoint) error {
|
func (c *Conn) Send(b []byte, ep conn.Endpoint) error {
|
||||||
as := ep.(*AddrSet)
|
var as *AddrSet
|
||||||
|
switch v := ep.(type) {
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unexpected Endpoint type %T", v))
|
||||||
|
case *singleEndpoint:
|
||||||
|
_, err := c.pconn.WriteTo(b, (*net.UDPAddr)(v))
|
||||||
|
return err
|
||||||
|
case *AddrSet:
|
||||||
|
as = v
|
||||||
|
}
|
||||||
|
|
||||||
var addrBuf [8]*net.UDPAddr
|
var addrBuf [8]*net.UDPAddr
|
||||||
dsts, roamAddr := appendDests(addrBuf[:0], as, b)
|
dsts, roamAddr := appendDests(addrBuf[:0], as, b)
|
||||||
|
Loading…
Reference in New Issue
Block a user