Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
ae516792
Unverified
Commit
ae516792
authored
6 years ago
by
takt
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #17 from hikhvar/fix/correct-ipv4-conversion
Fix/correct ipv4 conversion
parents
64b98409
10049697
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
net/helper.go
+1
-0
1 addition, 0 deletions
net/helper.go
net/helper_test.go
+6
-0
6 additions, 0 deletions
net/helper_test.go
routingtable/client_manager.go
+4
-0
4 additions, 0 deletions
routingtable/client_manager.go
with
11 additions
and
0 deletions
net/helper.go
+
1
−
0
View file @
ae516792
...
...
@@ -4,5 +4,6 @@ import "net"
// IPv4ToUint32 converts an `net.IP` to an uint32 interpretation
func
IPv4ToUint32
(
ip
net
.
IP
)
uint32
{
ip
=
ip
.
To4
()
return
uint32
(
ip
[
3
])
+
uint32
(
ip
[
2
])
<<
8
+
uint32
(
ip
[
1
])
<<
16
+
uint32
(
ip
[
0
])
<<
24
}
This diff is collapsed.
Click to expand it.
net/helper_test.go
+
6
−
0
View file @
ae516792
...
...
@@ -3,6 +3,8 @@ package net
import
(
"testing"
"net"
"github.com/stretchr/testify/assert"
)
...
...
@@ -23,6 +25,10 @@ func TestIPv4ToUint32(t *testing.T) {
input
:
[]
byte
{
172
,
24
,
5
,
1
},
expected
:
2887255297
,
},
{
input
:
net
.
ParseIP
(
"172.24.5.1"
),
expected
:
2887255297
,
},
}
for
_
,
test
:=
range
tests
{
...
...
This diff is collapsed.
Click to expand it.
routingtable/client_manager.go
+
4
−
0
View file @
ae516792
...
...
@@ -63,6 +63,8 @@ func (c *ClientManager) RegisterWithOptions(client RouteTableClient, opt ClientO
// Unregister unregisters a client
func
(
c
*
ClientManager
)
Unregister
(
client
RouteTableClient
)
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
if
_
,
ok
:=
c
.
clients
[
client
];
!
ok
{
return
}
...
...
@@ -71,6 +73,8 @@ func (c *ClientManager) Unregister(client RouteTableClient) {
// Clients returns a list of registered clients
func
(
c
*
ClientManager
)
Clients
()
[]
RouteTableClient
{
c
.
mu
.
RLock
()
defer
c
.
mu
.
RUnlock
()
ret
:=
make
([]
RouteTableClient
,
0
)
for
rtc
:=
range
c
.
clients
{
ret
=
append
(
ret
,
rtc
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment