mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 13:49:58 +00:00
TUN-5408: Update quic package to v0.24.0
This commit is contained in:

committed by
Chung Ting Huang

parent
157f5d1412
commit
e71b88fcaa
50
vendor/github.com/lucas-clemente/quic-go/conn_oob.go
generated
vendored
50
vendor/github.com/lucas-clemente/quic-go/conn_oob.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build darwin || linux || freebsd
|
||||
// +build darwin linux freebsd
|
||||
|
||||
package quic
|
||||
@@ -7,10 +8,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/net/ipv4"
|
||||
"golang.org/x/net/ipv6"
|
||||
@@ -238,50 +237,21 @@ func (info *packetInfo) OOB() []byte {
|
||||
// struct in_addr ipi_spec_dst; /* Local address */
|
||||
// struct in_addr ipi_addr; /* Header Destination address */
|
||||
// };
|
||||
msgLen := 12
|
||||
if runtime.GOOS == "freebsd" {
|
||||
msgLen = 4
|
||||
cm := ipv4.ControlMessage{
|
||||
Src: ip4,
|
||||
IfIndex: int(info.ifIndex),
|
||||
}
|
||||
cmsglen := cmsgLen(msgLen)
|
||||
oob := make([]byte, cmsglen)
|
||||
cmsg := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0]))
|
||||
cmsg.Level = syscall.IPPROTO_TCP
|
||||
cmsg.Type = msgTypeIPv4PKTINFO
|
||||
cmsg.SetLen(cmsglen)
|
||||
off := cmsgLen(0)
|
||||
if runtime.GOOS != "freebsd" {
|
||||
// FreeBSD does not support in_pktinfo, just an in_addr is sent
|
||||
binary.LittleEndian.PutUint32(oob[off:], info.ifIndex)
|
||||
off += 4
|
||||
}
|
||||
copy(oob[off:], ip4)
|
||||
return oob
|
||||
return cm.Marshal()
|
||||
} else if len(info.addr) == 16 {
|
||||
// struct in6_pktinfo {
|
||||
// struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
||||
// unsigned int ipi6_ifindex; /* send/recv interface index */
|
||||
// };
|
||||
const msgLen = 20
|
||||
cmsglen := cmsgLen(msgLen)
|
||||
oob := make([]byte, cmsglen)
|
||||
cmsg := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0]))
|
||||
cmsg.Level = syscall.IPPROTO_IPV6
|
||||
cmsg.Type = msgTypeIPv6PKTINFO
|
||||
cmsg.SetLen(cmsglen)
|
||||
off := cmsgLen(0)
|
||||
off += copy(oob[off:], info.addr)
|
||||
binary.LittleEndian.PutUint32(oob[off:], info.ifIndex)
|
||||
return oob
|
||||
cm := ipv6.ControlMessage{
|
||||
Src: info.addr,
|
||||
IfIndex: int(info.ifIndex),
|
||||
}
|
||||
return cm.Marshal()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cmsgLen(datalen int) int {
|
||||
return cmsgAlign(syscall.SizeofCmsghdr) + datalen
|
||||
}
|
||||
|
||||
func cmsgAlign(salen int) int {
|
||||
const sizeOfPtr = 0x8
|
||||
salign := sizeOfPtr
|
||||
return (salen + salign - 1) & ^(salign - 1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user