Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
d15e4235
Unverified
Commit
d15e4235
authored
Nov 23, 2021
by
Serhat Şevki Dinçer
Committed by
GitHub
Nov 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/enode: store local port number as uint16 (#23926)
parent
347c37b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
localnode.go
p2p/enode/localnode.go
+10
-7
types.go
p2p/simulations/adapters/types.go
+1
-1
No files found.
p2p/enode/localnode.go
View file @
d15e4235
...
@@ -63,7 +63,7 @@ type LocalNode struct {
...
@@ -63,7 +63,7 @@ type LocalNode struct {
type
lnEndpoint
struct
{
type
lnEndpoint
struct
{
track
*
netutil
.
IPTracker
track
*
netutil
.
IPTracker
staticIP
,
fallbackIP
net
.
IP
staticIP
,
fallbackIP
net
.
IP
fallbackUDP
in
t
fallbackUDP
uint16
// por
t
}
}
// NewLocalNode creates a local node.
// NewLocalNode creates a local node.
...
@@ -208,8 +208,8 @@ func (ln *LocalNode) SetFallbackUDP(port int) {
...
@@ -208,8 +208,8 @@ func (ln *LocalNode) SetFallbackUDP(port int) {
ln
.
mu
.
Lock
()
ln
.
mu
.
Lock
()
defer
ln
.
mu
.
Unlock
()
defer
ln
.
mu
.
Unlock
()
ln
.
endpoint4
.
fallbackUDP
=
port
ln
.
endpoint4
.
fallbackUDP
=
uint16
(
port
)
ln
.
endpoint6
.
fallbackUDP
=
port
ln
.
endpoint6
.
fallbackUDP
=
uint16
(
port
)
ln
.
updateEndpoints
()
ln
.
updateEndpoints
()
}
}
...
@@ -261,7 +261,7 @@ func (ln *LocalNode) updateEndpoints() {
...
@@ -261,7 +261,7 @@ func (ln *LocalNode) updateEndpoints() {
}
}
// get returns the endpoint with highest precedence.
// get returns the endpoint with highest precedence.
func
(
e
*
lnEndpoint
)
get
()
(
newIP
net
.
IP
,
newPort
int
)
{
func
(
e
*
lnEndpoint
)
get
()
(
newIP
net
.
IP
,
newPort
uint16
)
{
newPort
=
e
.
fallbackUDP
newPort
=
e
.
fallbackUDP
if
e
.
fallbackIP
!=
nil
{
if
e
.
fallbackIP
!=
nil
{
newIP
=
e
.
fallbackIP
newIP
=
e
.
fallbackIP
...
@@ -277,15 +277,18 @@ func (e *lnEndpoint) get() (newIP net.IP, newPort int) {
...
@@ -277,15 +277,18 @@ func (e *lnEndpoint) get() (newIP net.IP, newPort int) {
// predictAddr wraps IPTracker.PredictEndpoint, converting from its string-based
// predictAddr wraps IPTracker.PredictEndpoint, converting from its string-based
// endpoint representation to IP and port types.
// endpoint representation to IP and port types.
func
predictAddr
(
t
*
netutil
.
IPTracker
)
(
net
.
IP
,
int
)
{
func
predictAddr
(
t
*
netutil
.
IPTracker
)
(
net
.
IP
,
uint16
)
{
ep
:=
t
.
PredictEndpoint
()
ep
:=
t
.
PredictEndpoint
()
if
ep
==
""
{
if
ep
==
""
{
return
nil
,
0
return
nil
,
0
}
}
ipString
,
portString
,
_
:=
net
.
SplitHostPort
(
ep
)
ipString
,
portString
,
_
:=
net
.
SplitHostPort
(
ep
)
ip
:=
net
.
ParseIP
(
ipString
)
ip
:=
net
.
ParseIP
(
ipString
)
port
,
_
:=
strconv
.
Atoi
(
portString
)
port
,
err
:=
strconv
.
ParseUint
(
portString
,
10
,
16
)
return
ip
,
port
if
err
!=
nil
{
return
nil
,
0
}
return
ip
,
uint16
(
port
)
}
}
func
(
ln
*
LocalNode
)
invalidate
()
{
func
(
ln
*
LocalNode
)
invalidate
()
{
...
...
p2p/simulations/adapters/types.go
View file @
d15e4235
...
@@ -242,7 +242,7 @@ func assignTCPPort() (uint16, error) {
...
@@ -242,7 +242,7 @@ func assignTCPPort() (uint16, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
p
,
err
:=
strconv
.
Parse
Int
(
port
,
10
,
32
)
p
,
err
:=
strconv
.
Parse
Uint
(
port
,
10
,
16
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
...
...
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