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-sockaddr
Commits
6ab77f67
Commit
6ab77f67
authored
Jan 21, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't use ipv4 when a zone is set
parent
cda29e15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
net/net.go
net/net.go
+5
-0
No files found.
net/net.go
View file @
6ab77f67
...
@@ -115,6 +115,11 @@ func NetAddrToSockaddr(addr net.Addr) Sockaddr {
...
@@ -115,6 +115,11 @@ func NetAddrToSockaddr(addr net.Addr) Sockaddr {
// IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a Sockaddr
// IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a Sockaddr
// Returns nil if conversion fails.
// Returns nil if conversion fails.
func
IPAndZoneToSockaddr
(
ip
net
.
IP
,
zone
string
)
Sockaddr
{
func
IPAndZoneToSockaddr
(
ip
net
.
IP
,
zone
string
)
Sockaddr
{
if
zone
!=
""
{
var
buf
[
16
]
byte
copy
(
buf
[
:
],
ip
.
To16
())
return
&
SockaddrInet6
{
Addr
:
buf
,
ZoneId
:
uint32
(
IP6ZoneToInt
(
zone
))}
}
if
ip4
:=
ip
.
To4
();
ip4
!=
nil
{
if
ip4
:=
ip
.
To4
();
ip4
!=
nil
{
var
buf
[
4
]
byte
var
buf
[
4
]
byte
copy
(
buf
[
:
],
ip4
)
// last 4 bytes
copy
(
buf
[
:
],
ip4
)
// last 4 bytes
...
...
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