mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update kubernetes dep to 1.24.0
As kubernetes 1.24.0 is released, updating kubernetes dependencies to 1.24.0 updates: #3086 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
fc1529f268
commit
c4f79d455f
53
vendor/k8s.io/kubernetes/pkg/proxy/util/utils.go
generated
vendored
53
vendor/k8s.io/kubernetes/pkg/proxy/util/utils.go
generated
vendored
@ -78,6 +78,37 @@ func BuildPortsToEndpointsMap(endpoints *v1.Endpoints) map[string][]string {
|
||||
return portsToEndpoints
|
||||
}
|
||||
|
||||
// ContainsIPv4Loopback returns true if the input is empty or one of the CIDR contains an IPv4 loopback address.
|
||||
func ContainsIPv4Loopback(cidrStrings []string) bool {
|
||||
if len(cidrStrings) == 0 {
|
||||
return true
|
||||
}
|
||||
// RFC 5735 127.0.0.0/8 - This block is assigned for use as the Internet host loopback address
|
||||
ipv4LoopbackStart := netutils.ParseIPSloppy("127.0.0.0")
|
||||
for _, cidr := range cidrStrings {
|
||||
if IsZeroCIDR(cidr) {
|
||||
return true
|
||||
}
|
||||
|
||||
ip, ipnet, err := netutils.ParseCIDRSloppy(cidr)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if netutils.IsIPv6CIDR(ipnet) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ip.IsLoopback() {
|
||||
return true
|
||||
}
|
||||
if ipnet.Contains(ipv4LoopbackStart) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsZeroCIDR checks whether the input CIDR string is either
|
||||
// the IPv4 or IPv6 zero CIDR
|
||||
func IsZeroCIDR(cidr string) bool {
|
||||
@ -97,7 +128,7 @@ func IsProxyableIP(ip string) error {
|
||||
}
|
||||
|
||||
func isProxyableIP(ip net.IP) error {
|
||||
if ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() || ip.IsInterfaceLocalMulticast() {
|
||||
if !ip.IsGlobalUnicast() {
|
||||
return ErrAddressNotAllowed
|
||||
}
|
||||
return nil
|
||||
@ -490,7 +521,8 @@ func GetClusterIPByFamily(ipFamily v1.IPFamily, service *v1.Service) string {
|
||||
}
|
||||
|
||||
type LineBuffer struct {
|
||||
b bytes.Buffer
|
||||
b bytes.Buffer
|
||||
lines int
|
||||
}
|
||||
|
||||
// Write takes a list of arguments, each a string or []string, joins all the
|
||||
@ -516,22 +548,34 @@ func (buf *LineBuffer) Write(args ...interface{}) {
|
||||
}
|
||||
}
|
||||
buf.b.WriteByte('\n')
|
||||
buf.lines++
|
||||
}
|
||||
|
||||
// WriteBytes writes bytes to buffer, and terminates with newline.
|
||||
func (buf *LineBuffer) WriteBytes(bytes []byte) {
|
||||
buf.b.Write(bytes)
|
||||
buf.b.WriteByte('\n')
|
||||
buf.lines++
|
||||
}
|
||||
|
||||
// Reset clears buf
|
||||
func (buf *LineBuffer) Reset() {
|
||||
buf.b.Reset()
|
||||
buf.lines = 0
|
||||
}
|
||||
|
||||
// Bytes returns the contents of buf as a []byte
|
||||
func (buf *LineBuffer) Bytes() []byte {
|
||||
return buf.b.Bytes()
|
||||
}
|
||||
|
||||
// Lines returns the number of lines in buf. Note that more precisely, this returns the
|
||||
// number of times Write() or WriteBytes() was called; it assumes that you never wrote
|
||||
// any newlines to the buffer yourself.
|
||||
func (buf *LineBuffer) Lines() int {
|
||||
return buf.lines
|
||||
}
|
||||
|
||||
// RevertPorts is closing ports in replacementPortsMap but not in originalPortsMap. In other words, it only
|
||||
// closes the ports opened in this sync.
|
||||
func RevertPorts(replacementPortsMap, originalPortsMap map[netutils.LocalPort]netutils.Closeable) {
|
||||
@ -543,8 +587,3 @@ func RevertPorts(replacementPortsMap, originalPortsMap map[netutils.LocalPort]ne
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CountBytesLines counts the number of lines in a bytes slice
|
||||
func CountBytesLines(b []byte) int {
|
||||
return bytes.Count(b, []byte{'\n'})
|
||||
}
|
||||
|
Reference in New Issue
Block a user