1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 21:24:42 -05:00
sub2sing-box/parser/port.go
2024-11-06 18:38:59 +08:00

19 lines
278 B
Go
Executable File

package parser
import (
"errors"
"strconv"
)
func ParsePort(portStr string) (uint16, error) {
port, err := strconv.Atoi(portStr)
if err != nil {
return 0, err
}
if port < 1 || port > 65535 {
return 0, errors.New("invaild port range")
}
return uint16(port), nil
}