1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-07 11:39:11 -04:00

support for http and tls header sniffing

This commit is contained in:
Darien Raymond
2017-04-25 00:19:22 +02:00
parent a4212e7b48
commit 77521029b1
12 changed files with 487 additions and 156 deletions

View File

@@ -10,6 +10,7 @@ import (
"v2ray.com/core/app/dispatcher"
"v2ray.com/core/app/log"
"v2ray.com/core/app/proxyman"
"v2ray.com/core/common/buf"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy"
@@ -33,6 +34,7 @@ type tcpWorker struct {
recvOrigDest bool
tag string
dispatcher dispatcher.Interface
sniffers []proxyman.KnownProtocols
ctx context.Context
cancel context.CancelFunc
@@ -55,6 +57,9 @@ func (w *tcpWorker) callback(conn internet.Connection) {
}
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithSource(ctx, v2net.DestinationFromAddr(conn.RemoteAddr()))
if len(w.sniffers) > 0 {
ctx = proxyman.ContextWithProtocolSniffers(ctx, w.sniffers)
}
if err := w.proxy.Process(ctx, v2net.Network_TCP, conn, w.dispatcher); err != nil {
log.Trace(newError("connection ends").Base(err))
}