Update dependencies

This commit is contained in:
bluepython508
2024-11-01 17:33:34 +00:00
parent 033ac0b400
commit 5cdfab398d
3596 changed files with 1033483 additions and 259 deletions

1
vendor/github.com/tailscale/peercred/AUTHORS generated vendored Normal file
View File

@@ -0,0 +1 @@
Tailscale Inc

29
vendor/github.com/tailscale/peercred/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2021, Tailscale Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1
vendor/github.com/tailscale/peercred/README.md generated vendored Normal file
View File

@@ -0,0 +1 @@
# peercred

47
vendor/github.com/tailscale/peercred/peercred.go generated vendored Normal file
View File

@@ -0,0 +1,47 @@
// Copyright (c) 2021 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 peercred maps from a net.Conn to information about the
// other side of the connection, using various OS-specific facilities.
package peercred
import (
"errors"
"net"
"runtime"
)
// Creds are the peer credentials.
type Creds struct {
pid int
uid string
}
func (c *Creds) PID() (pid int, ok bool) {
return c.pid, c.pid != 0
}
// UserID returns the userid (or Windows SID) that owns the other side
// of the connection, if known. (ok is false if not known)
// The returned string is suitable to passing to os/user.LookupId.
func (c *Creds) UserID() (uid string, ok bool) {
return c.uid, c.uid != ""
}
var osGet func(net.Conn) (*Creds, error)
var (
ErrNotImplemented = errors.New("not implemented on " + runtime.GOOS)
ErrUnsupportedConnType = errors.New("unsupported connection type")
)
// Get returns the peer credentials for c.
//
// For unsupported system, the error is ErrNotImplemented.
func Get(c net.Conn) (*Creds, error) {
if osGet == nil {
return nil, ErrNotImplemented
}
return osGet(c)
}

View File

@@ -0,0 +1,62 @@
// Copyright (c) 2021 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 peercred
import (
"fmt"
"net"
"strconv"
"golang.org/x/sys/unix"
)
func init() {
osGet = getDarwin
}
func getDarwin(c net.Conn) (*Creds, error) {
switch c := c.(type) {
case *net.UnixConn:
return getUnix(c)
case *net.TCPConn:
// TODO: use /proc tcp info for localhost connections like Windows?
}
return nil, ErrUnsupportedConnType
}
func getUnix(c *net.UnixConn) (*Creds, error) {
raw, err := c.SyscallConn()
if err != nil {
return nil, fmt.Errorf("SyscallConn: %w", err)
}
var cred *unix.Xucred
var pid int
cerr := raw.Control(func(fd uintptr) {
cred, err = unix.GetsockoptXucred(int(fd),
unix.SOL_LOCAL,
unix.LOCAL_PEERCRED)
if err != nil {
err = fmt.Errorf("unix.GetsockoptXucred: %w", err)
return
}
pid, err = unix.GetsockoptInt(int(fd),
unix.SOL_LOCAL,
unix.LOCAL_PEERPID)
if err != nil {
err = fmt.Errorf("unix.GetsockoptInt: %w", err)
}
})
if cerr != nil {
return nil, fmt.Errorf("raw.Control: %w", cerr)
}
if err != nil {
return nil, err
}
return &Creds{
pid: pid,
uid: strconv.FormatUint(uint64(cred.Uid), 10),
}, nil
}

View File

@@ -0,0 +1,55 @@
// Copyright (c) 2021 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 peercred
import (
"fmt"
"net"
"strconv"
"golang.org/x/sys/unix"
)
func init() {
osGet = getFreeBSD
}
func getFreeBSD(c net.Conn) (*Creds, error) {
switch c := c.(type) {
case *net.UnixConn:
return getUnix(c)
case *net.TCPConn:
// TODO: use sysctl net.inet.tcp.pcblist for localhost connections like Windows?
}
return nil, ErrUnsupportedConnType
}
func getUnix(c *net.UnixConn) (*Creds, error) {
raw, err := c.SyscallConn()
if err != nil {
return nil, fmt.Errorf("SyscallConn: %w", err)
}
var cred *unix.Xucred
cerr := raw.Control(func(fd uintptr) {
cred, err = unix.GetsockoptXucred(int(fd),
unix.SOL_LOCAL,
unix.LOCAL_PEERCRED)
if err != nil {
err = fmt.Errorf("unix.GetsockoptXucred: %w", err)
return
}
})
if cerr != nil {
return nil, fmt.Errorf("raw.Control: %w", cerr)
}
if err != nil {
return nil, err
}
return &Creds{
pid: 0, // FreeBSD 13 adds a cr_pid field, can be used here.
uid: strconv.FormatUint(uint64(cred.Uid), 10),
}, nil
}

51
vendor/github.com/tailscale/peercred/peercred_linux.go generated vendored Normal file
View File

@@ -0,0 +1,51 @@
// Copyright (c) 2021 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 peercred
import (
"fmt"
"net"
"strconv"
"golang.org/x/sys/unix"
)
func init() {
osGet = getLinux
}
func getLinux(c net.Conn) (*Creds, error) {
switch c := c.(type) {
case *net.UnixConn:
return getUnix(c)
case *net.TCPConn:
// TODO: use /proc tcp info for localhost connections like Windows?
}
return nil, ErrUnsupportedConnType
}
func getUnix(c *net.UnixConn) (*Creds, error) {
raw, err := c.SyscallConn()
if err != nil {
return nil, fmt.Errorf("SyscallConn: %w", err)
}
var cred *unix.Ucred
cerr := raw.Control(func(fd uintptr) {
cred, err = unix.GetsockoptUcred(int(fd),
unix.SOL_SOCKET,
unix.SO_PEERCRED)
})
if cerr != nil {
return nil, fmt.Errorf("raw.Control: %w", cerr)
}
if err != nil {
return nil, fmt.Errorf("unix.GetsockoptUcred: %w", err)
}
return &Creds{
pid: int(cred.Pid),
uid: strconv.FormatUint(uint64(cred.Uid), 10),
}, nil
}