mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 01:33:15 +08:00
Refactor(tunnel): using parseAddr
This commit is contained in:
20
tunnel/util.go
Normal file
20
tunnel/util.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user