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
dfe50992
Commit
dfe50992
authored
Mar 29, 2019
by
idk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed up validators and encoders
parent
056263f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
transcoders.go
transcoders.go
+5
-7
No files found.
transcoders.go
View file @
dfe50992
...
...
@@ -254,8 +254,7 @@ func garlic32StB(s string) ([]byte, error) {
if
len
(
s
)
!=
52
||
len
(
s
)
<
55
||
len
(
s
)
>
63
{
return
nil
,
fmt
.
Errorf
(
"failed to parse garlic addr: %s not a i2p base32 address. len: %d"
,
s
,
len
(
s
))
}
garlicHostBytes
:=
make
([]
byte
,
37
)
_
,
err
:=
garlicBase32Encoding
.
Decode
(
garlicHostBytes
,
[]
byte
(
s
))
garlicHostBytes
,
err
:=
garlicBase32Encoding
.
Decode
(
s
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to decode base32 garlic addr: %s %s"
,
s
,
err
)
}
...
...
@@ -267,21 +266,20 @@ func garlic32StB(s string) ([]byte, error) {
}
func
garlic32BtS
(
b
[]
byte
)
(
string
,
error
)
{
if
len
(
b
)
<
3
3
||
len
(
b
)
>
3
7
{
return
""
,
fmt
.
Errorf
(
"failed to validate garlic addr: %s not an i2p base
64
address. len: %d
\n
"
,
b
,
len
(
b
))
if
len
(
b
)
!=
3
2
||
len
(
b
)
<
3
5
{
return
""
,
fmt
.
Errorf
(
"failed to validate garlic addr: %s not an i2p base
32
address. len: %d
\n
"
,
b
,
len
(
b
))
}
addr
:=
strings
.
Replace
(
strings
.
ToLower
(
garlicBase32Encoding
.
EncodeToString
(
b
)),
"="
,
""
,
-
1
)
return
addr
,
nil
}
func
garlic32Validate
(
b
[]
byte
)
error
{
if
len
(
b
)
<
3
3
||
len
(
b
)
>
3
7
{
return
fmt
.
Errorf
(
"failed to validate garlic addr: %s not an i2p base
64
address. len: %d
\n
"
,
b
,
len
(
b
))
if
len
(
b
)
!=
3
2
||
len
(
b
)
<
3
5
{
return
fmt
.
Errorf
(
"failed to validate garlic addr: %s not an i2p base
32
address. len: %d
\n
"
,
b
,
len
(
b
))
}
return
nil
}
var
TranscoderP2P
=
NewTranscoderFromFunctions
(
p2pStB
,
p2pBtS
,
p2pVal
)
func
p2pStB
(
s
string
)
([]
byte
,
error
)
{
...
...
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