Fixed: crash when net.ResolveIPAddr error
This commit is contained in:
parent
883ce4fea8
commit
2897ce916a
1 changed files with 7 additions and 2 deletions
|
@ -59,7 +59,12 @@ func handleTunneling(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func parseHttpAddr(target string) *C.Addr {
|
||||
host, port, _ := net.SplitHostPort(target)
|
||||
ipAddr, _ := net.ResolveIPAddr("ip", host)
|
||||
ipAddr, err := net.ResolveIPAddr("ip", host)
|
||||
var resolveIP *net.IP
|
||||
if err == nil {
|
||||
resolveIP = &ipAddr.IP
|
||||
}
|
||||
|
||||
var addType int
|
||||
ip := net.ParseIP(host)
|
||||
switch {
|
||||
|
@ -75,7 +80,7 @@ func parseHttpAddr(target string) *C.Addr {
|
|||
NetWork: C.TCP,
|
||||
AddrType: addType,
|
||||
Host: host,
|
||||
IP: &ipAddr.IP,
|
||||
IP: resolveIP,
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue