1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-23 22:04:41 -05:00
sub2clash/parser/port.go
2024-04-23 14:39:16 +08:00

19 lines
267 B
Go

package parser
import (
"errors"
"strconv"
)
func ParsePort(portStr string) (int, 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 port, nil
}