Refactor(tunnel): using parseAddr

This commit is contained in:
xjasonlyu
2021-07-19 14:04:17 +08:00
parent e77c12156a
commit ccc35c3c1b
4 changed files with 22 additions and 17 deletions

20
tunnel/util.go Normal file
View File

@@ -0,0 +1,20 @@
package tunnel
import (
"net"
"strconv"
)
func max(a, b int) int {
if a > b {
return a
}
return b
}
// parseAddr parses address to IP and port.
func parseAddr(addr string) (net.IP, uint16) {
host, portStr, _ := net.SplitHostPort(addr)
portInt, _ := strconv.ParseUint(portStr, 10, 16)
return net.ParseIP(host), uint16(portInt)
}