mirror of
https://github.com/go-gitea/gitea
synced 2024-11-05 01:34:25 +00:00
86e2789960
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
81 lines
3.5 KiB
Go
Vendored
81 lines
3.5 KiB
Go
Vendored
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ipv4
|
|
|
|
import (
|
|
"net"
|
|
"runtime"
|
|
"strings"
|
|
"syscall"
|
|
"unsafe"
|
|
|
|
"golang.org/x/net/internal/iana"
|
|
"golang.org/x/net/internal/socket"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
const sockoptReceiveInterface = unix.IP_RECVIF
|
|
|
|
var (
|
|
ctlOpts = [ctlMax]ctlOpt{
|
|
ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL},
|
|
ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst},
|
|
ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface},
|
|
}
|
|
|
|
sockOpts = map[int]*sockOpt{
|
|
ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}},
|
|
ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}},
|
|
ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}},
|
|
ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}},
|
|
ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 4}},
|
|
ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}},
|
|
ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}},
|
|
ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}},
|
|
ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}},
|
|
ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq},
|
|
ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq},
|
|
ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
|
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
|
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
|
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate")
|
|
if freebsdVersion >= 1000000 {
|
|
sockOpts[ssoMulticastInterface] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: unix.SizeofIPMreqn}, typ: ssoTypeIPMreqn}
|
|
}
|
|
if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" {
|
|
archs, _ := syscall.Sysctl("kern.supported_archs")
|
|
for _, s := range strings.Fields(archs) {
|
|
if s == "amd64" {
|
|
compatFreeBSD32 = true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func (gr *groupReq) setGroup(grp net.IP) {
|
|
sa := (*sockaddrInet)(unsafe.Pointer(&gr.Group))
|
|
sa.Len = sizeofSockaddrInet
|
|
sa.Family = syscall.AF_INET
|
|
copy(sa.Addr[:], grp)
|
|
}
|
|
|
|
func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) {
|
|
sa := (*sockaddrInet)(unsafe.Pointer(&gsr.Group))
|
|
sa.Len = sizeofSockaddrInet
|
|
sa.Family = syscall.AF_INET
|
|
copy(sa.Addr[:], grp)
|
|
sa = (*sockaddrInet)(unsafe.Pointer(&gsr.Source))
|
|
sa.Len = sizeofSockaddrInet
|
|
sa.Family = syscall.AF_INET
|
|
copy(sa.Addr[:], src)
|
|
}
|