mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-05 16:56:54 +08:00
21 lines
341 B
Go
21 lines
341 B
Go
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)
|
|
}
|