Skip to content

Commit

Permalink
fix error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 30, 2021
1 parent e2f4e4e commit 927b81c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions transcoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ var TranscoderOnion = NewTranscoderFromFunctions(onionStB, onionBtS, nil)
func onionStB(s string) ([]byte, error) {
addr := strings.Split(s, ":")
if len(addr) != 2 {
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number.", s)
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number", s)
}

// onion address without the ".onion" substring
if len(addr[0]) != 16 {
return nil, fmt.Errorf("failed to parse onion addr: %s not a Tor onion address.", s)
return nil, fmt.Errorf("failed to parse onion addr: %s not a Tor onion address", s)
}
onionHostBytes, err := base32.StdEncoding.DecodeString(strings.ToUpper(addr[0]))
if err != nil {
Expand Down Expand Up @@ -180,7 +180,7 @@ var TranscoderOnion3 = NewTranscoderFromFunctions(onion3StB, onion3BtS, nil)
func onion3StB(s string) ([]byte, error) {
addr := strings.Split(s, ":")
if len(addr) != 2 {
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number.", s)
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number", s)
}

// onion address without the ".onion" substring
Expand Down Expand Up @@ -228,7 +228,7 @@ func garlic64StB(s string) ([]byte, error) {
// i2p base64 address will be between 516 and 616 characters long, depending on
// certificate type
if len(s) < 516 || len(s) > 616 {
return nil, fmt.Errorf("failed to parse garlic addr: %s not an i2p base64 address. len: %d\n", s, len(s))
return nil, fmt.Errorf("failed to parse garlic addr: %s not an i2p base64 address. len: %d", s, len(s))
}
garlicHostBytes, err := garlicBase64Encoding.DecodeString(s)
if err != nil {
Expand All @@ -249,7 +249,7 @@ func garlic64BtS(b []byte) (string, error) {
func garlic64Validate(b []byte) error {
// A garlic64 address will always be greater than 386 bytes long when encoded.
if len(b) < 386 {
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base64 address. len: %d\n", b, len(b))
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base64 address. len: %d", b, len(b))
}
return nil
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func garlic32Validate(b []byte) error {
// an i2p base64 for an Encrypted Leaseset v2 will be at least 35 bytes
// long other than that, they will be exactly 32 bytes
if len(b) < 35 && len(b) != 32 {
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base32 address. len: %d\n", b, len(b))
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base32 address. len: %d", b, len(b))
}
return nil
}
Expand Down

0 comments on commit 927b81c

Please sign in to comment.