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
2e5c9e5c
Unverified
Commit
2e5c9e5c
authored
Aug 27, 2021
by
Manuel Buil
Committed by
GitHub
Aug 27, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3916 from manuelbuil/net_v6
Add functions to separate ipv4 and ipv6 CIDRs
parents
34dfe629
96dcef47
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 @
2e5c9e5c
...
...
@@ -63,3 +63,25 @@ func GetFirst4String(elems []string) (string, error) {
}
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