mirror of
https://github.com/go-gitea/gitea
synced 2024-11-12 05:04:24 +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>
46 lines
1.0 KiB
Go
Vendored
46 lines
1.0 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.
|
|
|
|
//go:build darwin || freebsd || linux
|
|
// +build darwin freebsd linux
|
|
|
|
package ipv4
|
|
|
|
import (
|
|
"net"
|
|
"unsafe"
|
|
|
|
"golang.org/x/net/internal/socket"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func (so *sockOpt) getIPMreqn(c *socket.Conn) (*net.Interface, error) {
|
|
b := make([]byte, so.Len)
|
|
if _, err := so.Get(c, b); err != nil {
|
|
return nil, err
|
|
}
|
|
mreqn := (*unix.IPMreqn)(unsafe.Pointer(&b[0]))
|
|
if mreqn.Ifindex == 0 {
|
|
return nil, nil
|
|
}
|
|
ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ifi, nil
|
|
}
|
|
|
|
func (so *sockOpt) setIPMreqn(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
|
|
var mreqn unix.IPMreqn
|
|
if ifi != nil {
|
|
mreqn.Ifindex = int32(ifi.Index)
|
|
}
|
|
if grp != nil {
|
|
mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]}
|
|
}
|
|
b := (*[unix.SizeofIPMreqn]byte)(unsafe.Pointer(&mreqn))[:unix.SizeofIPMreqn]
|
|
return so.Set(c, b)
|
|
}
|