mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-10-28 09:33:57 +00:00
🎨 Modify some code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -8,16 +9,10 @@ func ParsePort(portStr string) (uint16, error) {
|
||||
port, err := strconv.Atoi(portStr)
|
||||
|
||||
if err != nil {
|
||||
return 0, &ParseError{
|
||||
Type: ErrInvalidPort,
|
||||
Message: portStr,
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
if port < 1 || port > 65535 {
|
||||
return 0, &ParseError{
|
||||
Type: ErrInvalidPort,
|
||||
Message: portStr,
|
||||
}
|
||||
return 0, errors.New("invaild port range")
|
||||
}
|
||||
return uint16(port), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user