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
dms3
go-dms3
Commits
cb2fb9cf
Commit
cb2fb9cf
authored
Nov 02, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print NAT if detected
parent
2eac5aee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
net/conn/handshake.go
net/conn/handshake.go
+17
-3
No files found.
net/conn/handshake.go
View file @
cb2fb9cf
...
...
@@ -3,6 +3,7 @@ package conn
import
(
"errors"
"fmt"
"strings"
handshake
"github.com/jbenet/go-ipfs/net/handshake"
hspb
"github.com/jbenet/go-ipfs/net/handshake/pb"
...
...
@@ -105,6 +106,14 @@ func Handshake3(ctx context.Context, c Conn) error {
return
err
}
nat
,
err
:=
CheckNAT
(
remoteH
.
GetObservedAddr
())
if
err
!=
nil
{
log
.
Errorf
(
"Error in NAT detection: %s"
,
err
)
}
if
nat
{
log
.
Warning
(
"We are probably behind a NAT!"
)
}
return
nil
}
...
...
@@ -117,8 +126,13 @@ func CheckNAT(obsaddr string) (bool, error) {
if
err
!=
nil
{
return
false
,
err
}
_
=
oma
_
=
addrs
panic
(
"not yet implemented!"
)
omastr
:=
oma
.
String
()
for
_
,
addr
:=
range
addrs
{
if
strings
.
HasPrefix
(
addr
.
String
(),
omastr
)
{
return
false
,
nil
}
}
return
true
,
nil
}
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