整理代码

This commit is contained in:
2024-03-22 16:10:15 +08:00
committed by Nite07
parent f545848ce1
commit a7ceb4ecb0
16 changed files with 428 additions and 442 deletions

23
parser/port.go Normal file
View File

@@ -0,0 +1,23 @@
package parser
import (
"strconv"
)
func ParsePort(portStr string) (uint16, error) {
port, err := strconv.Atoi(portStr)
if err != nil {
return 0, &ParseError{
Type: ErrInvalidPort,
Message: portStr,
}
}
if port < 1 || port > 65535 {
return 0, &ParseError{
Type: ErrInvalidPort,
Message: portStr,
}
}
return uint16(port), nil
}