Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-tcp-transport
Commits
1dee40f5
Unverified
Commit
1dee40f5
authored
Nov 09, 2017
by
Steven Allen
Committed by
GitHub
Nov 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from libp2p/fix/source-address
fix source address not being set in non REUSEPORT dialer
parents
780d4133
5ebce0ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
tcp.go
tcp.go
+7
-10
No files found.
tcp.go
View file @
1dee40f5
...
...
@@ -52,6 +52,12 @@ func (t *TcpTransport) Dialer(laddr ma.Multiaddr, opts ...tpt.DialOpt) (tpt.Dial
}
var
base
manet
.
Dialer
la
,
err
:=
manet
.
ToNetAddr
(
laddr
)
if
err
!=
nil
{
return
nil
,
err
// something wrong with laddr.
}
base
.
Dialer
.
LocalAddr
=
la
var
doReuse
bool
for
_
,
o
:=
range
opts
{
switch
o
:=
o
.
(
type
)
{
...
...
@@ -137,12 +143,6 @@ type tcpDialer struct {
var
_
tpt
.
Dialer
=
&
tcpDialer
{}
func
(
t
*
TcpTransport
)
newTcpDialer
(
base
manet
.
Dialer
,
laddr
ma
.
Multiaddr
,
doReuse
bool
)
(
*
tcpDialer
,
error
)
{
// get the local net.Addr manually
la
,
err
:=
manet
.
ToNetAddr
(
laddr
)
if
err
!=
nil
{
return
nil
,
err
// something wrong with laddr.
}
var
pattern
mafmt
.
Pattern
if
TCP4
.
Matches
(
laddr
)
{
pattern
=
TCP4
...
...
@@ -154,10 +154,7 @@ func (t *TcpTransport) newTcpDialer(base manet.Dialer, laddr ma.Multiaddr, doReu
if
doReuse
&&
ReuseportIsAvailable
()
{
rd
:=
reuseport
.
Dialer
{
D
:
net
.
Dialer
{
LocalAddr
:
la
,
Timeout
:
base
.
Timeout
,
},
D
:
base
.
Dialer
,
}
return
&
tcpDialer
{
...
...
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