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
6f084e63
Commit
6f084e63
authored
Sep 14, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate ipv6 zone
parent
1f9df061
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
transcoders.go
transcoders.go
+10
-1
No files found.
transcoders.go
View file @
6f084e63
package
multiaddr
import
(
"bytes"
"encoding/base32"
"encoding/binary"
"fmt"
...
...
@@ -47,7 +48,7 @@ func (t twrp) ValidateBytes(b []byte) error {
var
TranscoderIP4
=
NewTranscoderFromFunctions
(
ip4StB
,
ipBtS
,
nil
)
var
TranscoderIP6
=
NewTranscoderFromFunctions
(
ip6StB
,
ipBtS
,
nil
)
var
TranscoderIP6Zone
=
NewTranscoderFromFunctions
(
ip6zoneStB
,
ip6zoneBtS
,
n
il
)
var
TranscoderIP6Zone
=
NewTranscoderFromFunctions
(
ip6zoneStB
,
ip6zoneBtS
,
i
p6zoneVa
l
)
func
ip4StB
(
s
string
)
([]
byte
,
error
)
{
i
:=
net
.
ParseIP
(
s
)
.
To4
()
...
...
@@ -71,6 +72,14 @@ func ip6zoneBtS(b []byte) (string, error) {
return
string
(
b
),
nil
}
func
ip6zoneVal
(
b
[]
byte
)
error
{
// Not supported as this would break multiaddrs.
if
bytes
.
IndexByte
(
b
,
'/'
)
>=
0
{
return
fmt
.
Errorf
(
"IPv6 zone ID contains '/': %s"
,
string
(
b
))
}
return
nil
}
func
ip6StB
(
s
string
)
([]
byte
,
error
)
{
i
:=
net
.
ParseIP
(
s
)
.
To16
()
if
i
==
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