mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Fixed: crash when net.ResolveIPAddr error
This commit is contained in:
parent
883ce4fea8
commit
2897ce916a
|
@ -59,7 +59,12 @@ func handleTunneling(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func parseHttpAddr(target string) *C.Addr {
|
func parseHttpAddr(target string) *C.Addr {
|
||||||
host, port, _ := net.SplitHostPort(target)
|
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
|
var addType int
|
||||||
ip := net.ParseIP(host)
|
ip := net.ParseIP(host)
|
||||||
switch {
|
switch {
|
||||||
|
@ -75,7 +80,7 @@ func parseHttpAddr(target string) *C.Addr {
|
||||||
NetWork: C.TCP,
|
NetWork: C.TCP,
|
||||||
AddrType: addType,
|
AddrType: addType,
|
||||||
Host: host,
|
Host: host,
|
||||||
IP: &ipAddr.IP,
|
IP: resolveIP,
|
||||||
Port: port,
|
Port: port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user