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
70e36376
Commit
70e36376
authored
Jun 21, 2016
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix port range check, port should no be greater than 65535.
parent
812b87c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
port_range.go
pkg/util/net/port_range.go
+6
-1
port_range_test.go
pkg/util/net/port_range_test.go
+3
-0
No files found.
pkg/util/net/port_range.go
View file @
70e36376
...
@@ -71,12 +71,17 @@ func (pr *PortRange) Set(value string) error {
...
@@ -71,12 +71,17 @@ func (pr *PortRange) Set(value string) error {
high
,
err
=
strconv
.
Atoi
(
value
[
hyphenIndex
+
1
:
])
high
,
err
=
strconv
.
Atoi
(
value
[
hyphenIndex
+
1
:
])
}
}
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to parse port range: %s"
,
value
)
return
fmt
.
Errorf
(
"unable to parse port range: %s: %v"
,
value
,
err
)
}
if
low
>
65535
||
high
>
65535
{
return
fmt
.
Errorf
(
"the port range cannot be greater than 65535: %s"
,
value
)
}
}
if
high
<
low
{
if
high
<
low
{
return
fmt
.
Errorf
(
"end port cannot be less than start port: %s"
,
value
)
return
fmt
.
Errorf
(
"end port cannot be less than start port: %s"
,
value
)
}
}
pr
.
Base
=
low
pr
.
Base
=
low
pr
.
Size
=
1
+
high
-
low
pr
.
Size
=
1
+
high
-
low
return
nil
return
nil
...
...
pkg/util/net/port_range_test.go
View file @
70e36376
...
@@ -38,6 +38,9 @@ func TestPortRange(t *testing.T) {
...
@@ -38,6 +38,9 @@ func TestPortRange(t *testing.T) {
{
"100 - 200"
,
false
,
""
,
-
1
,
-
1
},
{
"100 - 200"
,
false
,
""
,
-
1
,
-
1
},
{
"-100"
,
false
,
""
,
-
1
,
-
1
},
{
"-100"
,
false
,
""
,
-
1
,
-
1
},
{
"100-"
,
false
,
""
,
-
1
,
-
1
},
{
"100-"
,
false
,
""
,
-
1
,
-
1
},
{
"200-100"
,
false
,
""
,
-
1
,
-
1
},
{
"60000-70000"
,
false
,
""
,
-
1
,
-
1
},
{
"70000-80000"
,
false
,
""
,
-
1
,
-
1
},
}
}
for
i
:=
range
testCases
{
for
i
:=
range
testCases
{
...
...
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