Debian Codegraph @

pkg/util/net.go

raw symbols SCIP
1 /*
2 Copyright 2020 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package utilscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/
18
19 import (
20 "crypto/tlsscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/"
21 "stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/"
22 )
23
24 // containIPv6Addr checks if the given host identity contains an
25 // IPv6 address
26 func containIPv6Addrscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/containIPv6Addr().(host string) bool {
27 // the shortest IPv6 address is ::
28 return len(stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.Splitscip-go gomod github.com/golang/go/src go1.23.6 strings/Split().(host, ":")) > 2
29 }
30
31 // containPortIPv6 checks if the host that contains an IPv6 address
32 // also contains a port number
33 func containPortIPv6scip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/containPortIPv6().(host string) bool {
34 // based on to RFC 3986, section 3.2.2, host identified by an
35 // IPv6 is distinguished by enclosing the IP literal within square
36 // brackets ("[" and "]")
37 return stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.ContainsRunescip-go gomod github.com/golang/go/src go1.23.6 strings/ContainsRune().(host, '[')
38 }
39
40 // RemovePortFromHost removes port number from the host address that
41 // may be of the form "<host>:<port>" where the <host> can be an either
42 // an IPv4/6 address or a domain name
43 func RemovePortFromHostscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/RemovePortFromHost().(host string) string {
44 if !containIPv6Addrscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/containIPv6Addr().(host) {
45 return stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.Splitscip-go gomod github.com/golang/go/src go1.23.6 strings/Split().(host, ":")[0]
46 }
47 if containPortIPv6scip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/containPortIPv6().(host) {
48 host = host[:stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.LastIndexBytescip-go gomod github.com/golang/go/src go1.23.6 strings/LastIndexByte().(host, ':')]
49 }
50 return stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.Trimscip-go gomod github.com/golang/go/src go1.23.6 strings/Trim().(host, "[]")
51 }
52
53 // GetAcceptedCiphers returns all the ciphers supported by the crypto/tls package
54 func GetAcceptedCiphersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/GetAcceptedCiphers().() map[string]uint16 {
55 acceptedCiphers := make(map[string]uint16, len(tlsscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/.CipherSuitesscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/CipherSuites().()))
56 for _, v := range tlsscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/.CipherSuitesscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/CipherSuites().() {
57 acceptedCiphers[v.Namescip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/CipherSuite#Name.] = v.IDscip-go gomod github.com/golang/go/src go1.23.6 `crypto/tls`/CipherSuite#ID.
58 }
59 return acceptedCiphers
60 }