mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-08 08:37:12 +00:00
test case for sni proxy
This commit is contained in:
2 files changed
+107
-1
No files matched your search
@@ -66,7 +66,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
||||
|
||||
outbound := ray.NewRay(ctx)
|
||||
sniferList := proxyman.ProtocoSniffersFromContext(ctx)
|
||||
if len(sniferList) == 0 {
|
||||
if destination.Address.Family().IsDomain() || len(sniferList) == 0 {
|
||||
go d.routedDispatch(ctx, outbound, destination)
|
||||
} else {
|
||||
go func() {
|
||||
@@ -75,7 +75,9 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
||||
de := <-done
|
||||
if de.err != nil {
|
||||
log.Trace(newError("failed to snif").Base(de.err))
|
||||
return
|
||||
}
|
||||
log.Trace(newError("sniffed domain: ", de.domain))
|
||||
destination.Address = net.ParseAddress(de.domain)
|
||||
ctx = proxy.ContextWithTarget(ctx, destination)
|
||||
d.routedDispatch(ctx, outbound, destination)
|
||||
@@ -105,6 +107,9 @@ func snifer(ctx context.Context, sniferList []proxyman.KnownProtocols, outbound
|
||||
return
|
||||
}
|
||||
mb := outbound.OutboundInput().Peek()
|
||||
if mb.IsEmpty() {
|
||||
continue
|
||||
}
|
||||
nBytes, _ := mb.Read(payload)
|
||||
for _, protocol := range sniferList {
|
||||
var f func([]byte) (string, error)
|
||||
@@ -126,6 +131,13 @@ func snifer(ctx context.Context, sniferList []proxyman.KnownProtocols, outbound
|
||||
return
|
||||
}
|
||||
}
|
||||
if nBytes == 2048 {
|
||||
done <- domainOrError{
|
||||
domain: "",
|
||||
err: ErrInvalidData,
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user