mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-04 05:53:05 +00:00
fix how the padding is computed
This commit is contained in:
parent
946a6f66c0
commit
ae5c4f834c
@ -261,18 +261,14 @@ func garlic32StB(s string) ([]byte, error) {
|
|||||||
return nil, fmt.Errorf("failed to parse garlic addr: %s not a i2p base32 address. len: %d", s, len(s))
|
return nil, fmt.Errorf("failed to parse garlic addr: %s not a i2p base32 address. len: %d", s, len(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//compute the length to pad the address to, usually 56 or 64
|
||||||
for len(s) < 56 {
|
x := int((len(s)/8)+1) * 8
|
||||||
|
for len(s) < x {
|
||||||
s += "="
|
s += "="
|
||||||
}
|
}
|
||||||
|
garlicHostBytes, err := garlicBase32Encoding.DecodeString(s[0:56])
|
||||||
garlicHostBytes, err := garlicBase32Encoding.DecodeString(s)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode base32 garlic addr: %s, err: %v len: %v",
|
return nil, fmt.Errorf("failed to decode base32 garlic addr: %s, err: %v len: %v", s, err, len(s))
|
||||||
s,
|
|
||||||
err,
|
|
||||||
len(s),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return garlicHostBytes, nil
|
return garlicHostBytes, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user