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
mf
go-multiaddr
Commits
a4b7753f
Commit
a4b7753f
authored
Sep 13, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use constants, fix ipv6 bug
parent
b9067889
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
codec.go
codec.go
+7
-5
No files found.
codec.go
View file @
a4b7753f
...
...
@@ -66,12 +66,14 @@ func bytesToString(b []byte) (ret string, err error) {
func
addressStringToBytes
(
p
*
Protocol
,
s
string
)
[]
byte
{
switch
p
.
Code
{
// ipv4,6
case
4
,
41
:
case
P_IP4
:
// ipv4
return
net
.
ParseIP
(
s
)
.
To4
()
case
P_IP6
:
// ipv6
return
net
.
ParseIP
(
s
)
.
To16
()
// tcp udp dccp sctp
case
6
,
17
,
33
,
132
:
case
P_TCP
,
P_UDP
,
P_DCCP
,
P_SCTP
:
b
:=
make
([]
byte
,
2
)
i
,
err
:=
strconv
.
Atoi
(
s
)
if
err
==
nil
{
...
...
@@ -87,11 +89,11 @@ func addressBytesToString(p *Protocol, b []byte) string {
switch
p
.
Code
{
// ipv4,6
case
4
,
41
:
case
P_IP4
,
P_IP6
:
return
net
.
IP
(
b
)
.
String
()
// tcp udp dccp sctp
case
6
,
17
,
33
,
132
:
case
P_TCP
,
P_UDP
,
P_DCCP
,
P_SCTP
:
i
:=
binary
.
BigEndian
.
Uint16
(
b
)
return
strconv
.
Itoa
(
int
(
i
))
}
...
...
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