1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-18 13:35:23 +00:00

bug fixes in sniffer

This commit is contained in:
Darien Raymond 2017-04-26 00:43:59 +02:00
parent 4668f9d3de
commit 7c59b2e224
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 5 additions and 7 deletions

View File

@ -70,13 +70,11 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
} else {
go func() {
domain, err := snifer(ctx, sniferList, outbound)
if err != nil {
log.Trace(newError("failed to snif").Base(err))
return
if err == nil {
log.Trace(newError("sniffed domain: ", domain))
destination.Address = net.ParseAddress(domain)
ctx = proxy.ContextWithTarget(ctx, destination)
}
log.Trace(newError("sniffed domain: ", domain))
destination.Address = net.ParseAddress(domain)
ctx = proxy.ContextWithTarget(ctx, destination)
d.routedDispatch(ctx, outbound, destination)
}()
}

View File

@ -45,7 +45,7 @@ func SniffHTTP(b []byte) (string, error) {
value := strings.ToLower(string(bytes.Trim(parts[1], " ")))
if key == "host" {
domain := strings.Split(value, ":")
return domain[0], nil
return strings.TrimSpace(domain[0]), nil
}
}
return "", ErrMoreData