Documentation ¶
Overview ¶
Copyright (c) 2021-2022 Tigera, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2021 Tigera, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016 Tigera, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016 Tigera, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2017 Tigera, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( AUTODETECTION_METHOD_FIRST = "first-found" AUTODETECTION_METHOD_CAN_REACH = "can-reach=" AUTODETECTION_METHOD_INTERFACE = "interface=" AUTODETECTION_METHOD_SKIP_INTERFACE = "skip-interface=" AUTODETECTION_METHOD_CIDR = "cidr=" K8S_INTERNAL_IP = "kubernetes-internal-ip" )
Variables ¶
var DEFAULT_INTERFACES_TO_EXCLUDE []string = []string{
"^docker.*", "^cbr.*", "^dummy.*", "^podman.*",
"^virbr.*", "^lxcbr.*", "^veth.*", "^lo", "^br-.*",
"^cali.*", "^tunl.*", "^flannel.*", "^kube-ipvs.*", "^cni.*",
"^vxlan\\.calico.*", "^vxlan-v6\\.calico.*", "^wireguard\\.cali.*", "^wg-v6\\.cali.*",
"^nodelocaldns.*",
}
Default interfaces to exclude for any logic following the first-found auto detect IP method
Functions ¶
func AutoDetectCIDR ¶
func AutoDetectCIDR(method string, version int, k8sNode *v1.Node, getInterfaces func([]string, []string, int) ([]Interface, error)) *cnet.IPNet
autoDetectCIDR auto-detects the IP and Network using the requested detection method.
func GetLocalCIDR ¶
func GetLocalCIDR(ip string, version int, getInterfaces func([]string, []string, int) ([]Interface, error)) (string, error)
getLocalCIDR attempts to merge CIDR information from the host with the given IP address. If a CIDR is provided, then it is simply returned. If an IP is provided, it attempts to find the matching interface on the host to detect the appropriate prefix length. If no match is found, the IP will be returned unmodified.
Types ¶
type Interface ¶
Interface contains details about an interface on the host.
func FilteredEnumeration ¶
func FilteredEnumeration(incl, excl []string, cidrs []net.IPNet, version int) (*Interface, *net.IPNet, error)
FilteredEnumeration performs basic IP and IPNetwork discovery by enumerating all interfaces and filtering in/out based on the supplied filter regex.
The incl and excl slice of regex strings may be nil.
func GetInterfaces ¶
func GetInterfaces(getSystemInterfaces func() ([]net.Interface, error), includeRegexes []string, excludeRegexes []string, version int) ([]Interface, error)
GetInterfaces returns a list of all interfaces, skipping any interfaces whose name matches any of the exclusion list regexes, and including those on the inclusion list.