Ensure port is above minimum port number for onions

This commit is contained in:
David Stainton 2015-09-26 01:35:58 +02:00
parent d30c844a21
commit fca4278010
1 changed files with 5 additions and 1 deletions

View File

@ -187,8 +187,12 @@ func addressStringToBytes(p Protocol, s string) ([]byte, error) {
return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, err)
}
if i >= 65536 {
return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, "greater than 65536")
return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, "port greater than 65536")
}
if i < 1 {
return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, "port less than 1")
}
onionPortBytes := make([]byte, 2)
binary.BigEndian.PutUint16(onionPortBytes, uint16(i))
bytes := []byte{}