Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
96dcef47
Commit
96dcef47
authored
Aug 26, 2021
by
Manuel Buil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functions to separate ipv4 from ipv6 functions
Signed-off-by:
Manuel Buil
<
mbuil@suse.com
>
parent
c23e63ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
net.go
pkg/util/net.go
+22
-0
No files found.
pkg/util/net.go
View file @
96dcef47
...
@@ -63,3 +63,25 @@ func GetFirst4String(elems []string) (string, error) {
...
@@ -63,3 +63,25 @@ func GetFirst4String(elems []string) (string, error) {
}
}
return
ip
.
String
(),
nil
return
ip
.
String
(),
nil
}
}
// JoinIP4Nets stringifies and joins a list of IPv4 networks with commas.
func
JoinIP4Nets
(
elems
[]
*
net
.
IPNet
)
string
{
var
strs
[]
string
for
_
,
elem
:=
range
elems
{
if
elem
!=
nil
&&
elem
.
IP
.
To4
()
!=
nil
{
strs
=
append
(
strs
,
elem
.
String
())
}
}
return
strings
.
Join
(
strs
,
","
)
}
// JoinIP6Nets stringifies and joins a list of IPv6 networks with commas.
func
JoinIP6Nets
(
elems
[]
*
net
.
IPNet
)
string
{
var
strs
[]
string
for
_
,
elem
:=
range
elems
{
if
elem
!=
nil
&&
elem
.
IP
.
To4
()
==
nil
{
strs
=
append
(
strs
,
elem
.
String
())
}
}
return
strings
.
Join
(
strs
,
","
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment