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
58c18c3a
Unverified
Commit
58c18c3a
authored
Nov 25, 2018
by
idk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using base64 i2p addresses to facilitate transport
parent
cf7ed7c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
29 deletions
+31
-29
multiaddr_test.go
multiaddr_test.go
+20
-20
transcoders.go
transcoders.go
+11
-9
No files found.
multiaddr_test.go
View file @
58c18c3a
...
...
@@ -44,18 +44,18 @@ func TestConstructFails(t *testing.T) {
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:-1"
,
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd"
,
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyy@:666"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
7:80"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:0"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:0"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:-1"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniss47li5r6ugoertzuq
@:666"
,
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
"
,
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
7:80"
,
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:0"
,
"/garlicu/
566niximl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QzCKEWAyzrQkBfo2avGAmmz2NaHaAvYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
@:666"
,
"/udp/1234/sctp"
,
"/udp/1234/udt/1234"
,
"/udp/1234/utp/1234"
,
...
...
@@ -94,10 +94,10 @@ func TestConstructSucceeds(t *testing.T) {
"/onion/timaq4ygg2iegci7:80/http"
,
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234"
,
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:80/http"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:80/http"
,
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:80/http"
,
"/garlict/
jT~IyXaoauTni6N4517EG8mrFUKpy0IlgZh-EY9csMAk82Odatmzr~YTZy8Hv7u~wvkg75EFNOyqb~nAPg-khyp2TS~ObUz8WlqYAM2VlEzJ7wJB91P-cUlKF18zSzVoJFmsrcQHZCirSbWoOknS6iNmsGRh5KVZsBEfp1Dg3gwTipTRIx7Vl5Vy~1OSKQVjYiGZS9q8RL0MF~7xFiKxZDLbPxk0AK9TzGGqm~wMTI2HS0Gm4Ycy8LYPVmLvGonIBYndg2bJC7WLuF6tVjVquiokSVDKFwq70BCUU5AU-EvdOD5KEOAM7mPfw-gJUG4tm1TtvcobrObqoRnmhXPTBTN5H7qDD12AvlwFGnfAlBXjuP4xOUAISL5SRLiulrsMSiT4GcugSI80mF6sdB0zWRgL1yyvoVWeTBn1TqjO27alr95DGTluuSqrNAxgpQzCKEWAyzrQkBfo2avGAmmz2NaHaAvYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
:1234"
,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
jT~IyXaoauTni6N4517EG8mrFUKpy0IlgZh-EY9csMAk82Odatmzr~YTZy8Hv7u~wvkg75EFNOyqb~nAPg-khyp2TS~ObUz8WlqYAM2VlEzJ7wJB91P-cUlKF18zSzVoJFmsrcQHZCirSbWoOknS6iNmsGRh5KVZsBEfp1Dg3gwTipTRIx7Vl5Vy~1OSKQVjYiGZS9q8RL0MF~7xFiKxZDLbPxk0AK9TzGGqm~wMTI2HS0Gm4Ycy8LYPVmLvGonIBYndg2bJC7WLuF6tVjVquiokSVDKFwq70BCUU5AU-EvdOD5KEOAM7mPfw-gJUG4tm1TtvcobrObqoRnmhXPTBTN5H7qDD12AvlwFGnfAlBXjuP4xOUAISL5SRLiulrsMSiT4GcugSI80mF6sdB0zWRgL1yyvoVWeTBn1TqjO27alr95DGTluuSqrNAxgpQzCKEWAyzrQkBfo2avGAmmz2NaHaAvYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
:80/http"
,
"/udp/0"
,
"/tcp/0"
,
"/sctp/0"
,
...
...
@@ -199,8 +199,8 @@ func TestStringToBytes(t *testing.T) {
testString
(
"/ip4/127.0.0.1/udp/1234/ip4/127.0.0.1/tcp/4321"
,
"047f000001910204d2047f0000010610e1"
)
testString
(
"/onion/aaimaq4ygg2iegci:80"
,
"bc030010c0439831b48218480050"
)
testString
(
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234"
,
"bd03adadec040be047f9658668b11a504f3155001f231a37f54c4476c07fb4cc139ed7e30304d2"
)
testString
(
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"ca03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2"
)
testString
(
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"cb03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2"
)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vYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
:1234", "cb03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2")
}
...
...
@@ -232,8 +232,8 @@ func TestBytesToString(t *testing.T) {
testString
(
"/ip4/127.0.0.1/udp/1234/ip4/127.0.0.1/tcp/4321"
,
"047f000001910204d2047f0000010610e1"
)
testString
(
"/onion/aaimaq4ygg2iegci:80"
,
"bc030010c0439831b48218480050"
)
testString
(
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234"
,
"bd03adadec040be047f9658668b11a504f3155001f231a37f54c4476c07fb4cc139ed7e30304d2"
)
testString
(
"/garlict/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"ca03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2"
)
testString
(
"/garlicu/
566niximlxdzpanmn4qouucvua3k7neniwss47li5r6ugoertzuq
:1234"
,
"cb03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2"
)
//
testString("/garlict/
jT~IyXaoauTni6N4517EG8mrFUKpy0IlgZh-EY9csMAk82Odatmzr~YTZy8Hv7u~wvkg75EFNOyqb~nAPg-khyp2TS~ObUz8WlqYAM2VlEzJ7wJB91P-cUlKF18zSzVoJFmsrcQHZCirSbWoOknS6iNmsGRh5KVZsBEfp1Dg3gwTipTRIx7Vl5Vy~1OSKQVjYiGZS9q8RL0MF~7xFiKxZDLbPxk0AK9TzGGqm~wMTI2HS0Gm4Ycy8LYPVmLvGonIBYndg2bJC7WLuF6tVjVquiokSVDKFwq70BCUU5AU-EvdOD5KEOAM7mPfw-gJUG4tm1TtvcobrObqoRnmhXPTBTN5H7qDD12AvlwFGnfAlBXjuP4xOUAISL5SRLiulrsMSiT4GcugSI80mF6sdB0zWRgL1yyvoVWeTBn1TqjO27alr95DGTluuSqrNAxgpQzCKEWAyzrQkBfo2avGAmmz2NaHaAvYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
:1234", "ca03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2")
//
testString("/garlicu/
jT~IyXaoauTni6N4517EG8mrFUKpy0IlgZh-EY9csMAk82Odatmzr~YTZy8Hv7u~wvkg75EFNOyqb~nAPg-khyp2TS~ObUz8WlqYAM2VlEzJ7wJB91P-cUlKF18zSzVoJFmsrcQHZCirSbWoOknS6iNmsGRh5KVZsBEfp1Dg3gwTipTRIx7Vl5Vy~1OSKQVjYiGZS9q8RL0MF~7xFiKxZDLbPxk0AK9TzGGqm~wMTI2HS0Gm4Ycy8LYPVmLvGonIBYndg2bJC7WLuF6tVjVquiokSVDKFwq70BCUU5AU-EvdOD5KEOAM7mPfw-gJUG4tm1TtvcobrObqoRnmhXPTBTN5H7qDD12AvlwFGnfAlBXjuP4xOUAISL5SRLiulrsMSiT4GcugSI80mF6sdB0zWRgL1yyvoVWeTBn1TqjO27alr95DGTluuSqrNAxgpQzCKEWAyzrQkBfo2avGAmmz2NaHaAvYbOg0QSJz1PLjv2jdPW~ofiQmrGWM1cd~1cCqAAAA
:1234", "cb03efbcd45d0c5dc79781ac6f20ea5055a036afb48d45a52e7d68ec7d4338919e6904d2")
}
func
TestBytesSplitAndJoin
(
t
*
testing
.
T
)
{
...
...
transcoders.go
View file @
58c18c3a
...
...
@@ -3,6 +3,7 @@ package multiaddr
import
(
"bytes"
"encoding/base32"
"encoding/base64"
"encoding/binary"
"fmt"
"net"
...
...
@@ -218,14 +219,14 @@ func garlicStB(s string) ([]byte, error) {
if
len
(
addr
)
!=
2
{
return
nil
,
fmt
.
Errorf
(
"failed to parse garlic addr: %s does not contain a port number."
,
s
)
}
//
garlic address without the ".b32.i2p" substring, with padding
if
len
(
addr
[
0
]
)
!
=
5
2
{
return
nil
,
fmt
.
Errorf
(
"failed to parse garlic addr: %s not a i2p base
32
address. len: %d"
,
s
,
len
(
addr
[
0
]))
//
i2p base64 address
if
len
(
addr
)
==
4096
||
len
(
addr
)
=
=
5
16
{
return
nil
,
fmt
.
Errorf
(
"failed to parse garlic addr: %s not a i2p base
64
address. len: %d
\n
"
,
s
,
len
(
addr
[
0
]))
}
garlicHostBytes
:=
make
([]
byte
,
32
)
_
,
err
:=
base
32
.
NewEncoding
(
"abcdefghijklmnopqrstuvwxyz234567"
)
.
Decode
(
garlicHostBytes
,
[]
byte
(
addr
[
0
]
+
"===="
)
)
garlicHostBytes
:=
make
([]
byte
,
len
(
addr
)
)
_
,
err
:=
base
64
.
NewEncoding
(
"
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
01
234567
89-~
"
)
.
Decode
String
(
addr
[
0
]
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to decode base
32 garlic
addr: %s
%s
%s"
,
s
,
err
,
string
(
s
[
48
])
)
return
nil
,
fmt
.
Errorf
(
"failed to decode base
64 i2p
addr: %s %s"
,
s
,
err
)
}
// garlic port number
...
...
@@ -243,14 +244,15 @@ func garlicStB(s string) ([]byte, error) {
garlicPortBytes
:=
make
([]
byte
,
2
)
binary
.
BigEndian
.
PutUint16
(
garlicPortBytes
,
uint16
(
i
))
bytes
:=
[]
byte
{}
bytes
=
append
(
bytes
,
garlicHostBytes
[
0
:
32
]
...
)
bytes
=
append
(
bytes
,
garlicHostBytes
[
0
:
len
(
addr
)
]
...
)
bytes
=
append
(
bytes
,
garlicPortBytes
...
)
return
bytes
,
nil
}
func
garlicBtS
(
b
[]
byte
)
(
string
,
error
)
{
addr
:=
strings
.
Replace
(
strings
.
ToLower
(
base32
.
NewEncoding
(
"abcdefghijklmnopqrstuvwxyz234567"
)
.
EncodeToString
(
b
[
0
:
32
])),
"="
,
""
,
-
1
)
port
:=
binary
.
BigEndian
.
Uint16
(
b
[
32
:
34
])
baddr
:=
b
[
0
:
len
(
b
)
-
3
]
addr
:=
strings
.
Replace
(
strings
.
ToLower
(
base64
.
NewEncoding
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-~"
)
.
EncodeToString
(
baddr
)),
"="
,
""
,
-
1
)
port
:=
binary
.
BigEndian
.
Uint16
(
b
[
len
(
b
)
-
3
:
len
(
b
)
-
1
])
str
:=
addr
+
":"
+
strconv
.
Itoa
(
int
(
port
))
return
str
,
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