mirror of
https://github.com/rancher/plugins.git
synced 2025-07-09 05:04:51 +00:00
Bumps the golang group with 5 updates: | Package | From | To | | --- | --- | --- | | [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) | `0.11.4` | `0.12.0` | | [github.com/alexflint/go-filemutex](https://github.com/alexflint/go-filemutex) | `1.2.0` | `1.3.0` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.13.2` | `2.16.0` | | [github.com/onsi/gomega](https://github.com/onsi/gomega) | `1.30.0` | `1.31.1` | | [golang.org/x/sys](https://github.com/golang/sys) | `0.15.0` | `0.17.0` | Updates `github.com/Microsoft/hcsshim` from 0.11.4 to 0.12.0 - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.11.4...v0.12.0) Updates `github.com/alexflint/go-filemutex` from 1.2.0 to 1.3.0 - [Release notes](https://github.com/alexflint/go-filemutex/releases) - [Commits](https://github.com/alexflint/go-filemutex/compare/v1.2.0...v1.3.0) Updates `github.com/onsi/ginkgo/v2` from 2.13.2 to 2.16.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.13.2...v2.16.0) Updates `github.com/onsi/gomega` from 1.30.0 to 1.31.1 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.30.0...v1.31.1) Updates `golang.org/x/sys` from 0.15.0 to 0.17.0 - [Commits](https://github.com/golang/sys/compare/v0.15.0...v0.17.0) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/alexflint/go-filemutex dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang ... Signed-off-by: dependabot[bot] <support@github.com>
123 lines
2.5 KiB
Go
123 lines
2.5 KiB
Go
// Copyright 2012 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 aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || windows
|
|
|
|
package ipv4
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
"unsafe"
|
|
|
|
"golang.org/x/net/internal/socket"
|
|
)
|
|
|
|
var errNoSuchInterface = errors.New("no such interface")
|
|
|
|
func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
|
|
mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
|
|
if err := setIPMreqInterface(&mreq, ifi); err != nil {
|
|
return err
|
|
}
|
|
b := (*[sizeofIPMreq]byte)(unsafe.Pointer(&mreq))[:sizeofIPMreq]
|
|
return so.Set(c, b)
|
|
}
|
|
|
|
func (so *sockOpt) getMulticastIf(c *socket.Conn) (*net.Interface, error) {
|
|
var b [4]byte
|
|
if _, err := so.Get(c, b[:]); err != nil {
|
|
return nil, err
|
|
}
|
|
ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3]))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ifi, nil
|
|
}
|
|
|
|
func (so *sockOpt) setMulticastIf(c *socket.Conn, ifi *net.Interface) error {
|
|
ip, err := netInterfaceToIP4(ifi)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var b [4]byte
|
|
copy(b[:], ip)
|
|
return so.Set(c, b[:])
|
|
}
|
|
|
|
func setIPMreqInterface(mreq *ipMreq, ifi *net.Interface) error {
|
|
if ifi == nil {
|
|
return nil
|
|
}
|
|
ifat, err := ifi.Addrs()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, ifa := range ifat {
|
|
switch ifa := ifa.(type) {
|
|
case *net.IPAddr:
|
|
if ip := ifa.IP.To4(); ip != nil {
|
|
copy(mreq.Interface[:], ip)
|
|
return nil
|
|
}
|
|
case *net.IPNet:
|
|
if ip := ifa.IP.To4(); ip != nil {
|
|
copy(mreq.Interface[:], ip)
|
|
return nil
|
|
}
|
|
}
|
|
}
|
|
return errNoSuchInterface
|
|
}
|
|
|
|
func netIP4ToInterface(ip net.IP) (*net.Interface, error) {
|
|
ift, err := net.Interfaces()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, ifi := range ift {
|
|
ifat, err := ifi.Addrs()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, ifa := range ifat {
|
|
switch ifa := ifa.(type) {
|
|
case *net.IPAddr:
|
|
if ip.Equal(ifa.IP) {
|
|
return &ifi, nil
|
|
}
|
|
case *net.IPNet:
|
|
if ip.Equal(ifa.IP) {
|
|
return &ifi, nil
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil, errNoSuchInterface
|
|
}
|
|
|
|
func netInterfaceToIP4(ifi *net.Interface) (net.IP, error) {
|
|
if ifi == nil {
|
|
return net.IPv4zero.To4(), nil
|
|
}
|
|
ifat, err := ifi.Addrs()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, ifa := range ifat {
|
|
switch ifa := ifa.(type) {
|
|
case *net.IPAddr:
|
|
if ip := ifa.IP.To4(); ip != nil {
|
|
return ip, nil
|
|
}
|
|
case *net.IPNet:
|
|
if ip := ifa.IP.To4(); ip != nil {
|
|
return ip, nil
|
|
}
|
|
}
|
|
}
|
|
return nil, errNoSuchInterface
|
|
}
|