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
42212808
Unverified
Commit
42212808
authored
Dec 07, 2022
by
Seungbae Yu
Committed by
GitHub
Dec 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/nat: handle responses with alternative port in NAT-PMP (#26321)
Co-authored-by:
Felix Lange
<
fjl@twurst.com
>
parent
f20eba42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
natpmp.go
p2p/nat/natpmp.go
+16
-2
No files found.
p2p/nat/natpmp.go
View file @
42212808
...
...
@@ -50,8 +50,22 @@ func (n *pmp) AddMapping(protocol string, extport, intport int, name string, lif
}
// Note order of port arguments is switched between our
// AddMapping and the client's AddPortMapping.
_
,
err
:=
n
.
c
.
AddPortMapping
(
strings
.
ToLower
(
protocol
),
intport
,
extport
,
int
(
lifetime
/
time
.
Second
))
return
err
res
,
err
:=
n
.
c
.
AddPortMapping
(
strings
.
ToLower
(
protocol
),
intport
,
extport
,
int
(
lifetime
/
time
.
Second
))
if
err
!=
nil
{
return
err
}
// NAT-PMP maps an alternative available port number if the requested
// port is already mapped to another address and returns success. In this
// case, we return an error because there is no way to return the new port
// to the caller.
if
uint16
(
extport
)
!=
res
.
MappedExternalPort
{
// Destroy the mapping in NAT device.
n
.
c
.
AddPortMapping
(
strings
.
ToLower
(
protocol
),
intport
,
0
,
0
)
return
fmt
.
Errorf
(
"port %d already mapped to another address (%s)"
,
extport
,
protocol
)
}
return
nil
}
func
(
n
*
pmp
)
DeleteMapping
(
protocol
string
,
extport
,
intport
int
)
(
err
error
)
{
...
...
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