@@ -254,8 +254,7 @@ func garlic32StB(s string) ([]byte, error) {
254
254
if len (s ) != 52 || len (s ) < 55 || len (s ) > 63 {
255
255
return nil , fmt .Errorf ("failed to parse garlic addr: %s not a i2p base32 address. len: %d" , s , len (s ))
256
256
}
257
- garlicHostBytes := make ([]byte , 37 )
258
- _ , err := garlicBase32Encoding .Decode (garlicHostBytes , []byte (s ))
257
+ garlicHostBytes , err := garlicBase32Encoding .Decode (s )
259
258
if err != nil {
260
259
return nil , fmt .Errorf ("failed to decode base32 garlic addr: %s %s" , s , err )
261
260
}
@@ -267,21 +266,20 @@ func garlic32StB(s string) ([]byte, error) {
267
266
}
268
267
269
268
func garlic32BtS (b []byte ) (string , error ) {
270
- if len (b ) < 33 || len (b ) > 37 {
271
- return "" , fmt .Errorf ("failed to validate garlic addr: %s not an i2p base64 address. len: %d\n " , b , len (b ))
269
+ if len (b ) != 32 || len (b ) < 35 {
270
+ return "" , fmt .Errorf ("failed to validate garlic addr: %s not an i2p base32 address. len: %d\n " , b , len (b ))
272
271
}
273
272
addr := strings .Replace (strings .ToLower (garlicBase32Encoding .EncodeToString (b )), "=" , "" , - 1 )
274
273
return addr , nil
275
274
}
276
275
277
276
func garlic32Validate (b []byte ) error {
278
- if len (b ) < 33 || len (b ) > 37 {
279
- return fmt .Errorf ("failed to validate garlic addr: %s not an i2p base64 address. len: %d\n " , b , len (b ))
277
+ if len (b ) != 32 || len (b ) < 35 {
278
+ return fmt .Errorf ("failed to validate garlic addr: %s not an i2p base32 address. len: %d\n " , b , len (b ))
280
279
}
281
280
return nil
282
281
}
283
282
284
-
285
283
var TranscoderP2P = NewTranscoderFromFunctions (p2pStB , p2pBtS , p2pVal )
286
284
287
285
func p2pStB (s string ) ([]byte , error ) {
0 commit comments