mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 14:57:44 -05:00
Fix stat
This commit is contained in:
parent
553bf3368b
commit
f06ede1bc1
@ -14,6 +14,7 @@ import (
|
|||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/signal"
|
"v2ray.com/core/common/signal"
|
||||||
|
"v2ray.com/core/features/stats"
|
||||||
"v2ray.com/core/proxy/vless"
|
"v2ray.com/core/proxy/vless"
|
||||||
"v2ray.com/core/transport/internet/xtls"
|
"v2ray.com/core/transport/internet/xtls"
|
||||||
)
|
)
|
||||||
@ -173,18 +174,23 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A
|
|||||||
return responseAddons, nil
|
return responseAddons, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn *xtls.Conn, rawConn syscall.RawConn) error {
|
func ReadV(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn *xtls.Conn, rawConn syscall.RawConn, counter stats.Counter) error {
|
||||||
err := func() error {
|
err := func() error {
|
||||||
|
var ct stats.Counter
|
||||||
for {
|
for {
|
||||||
if conn.DirectIn {
|
if conn.DirectIn {
|
||||||
conn.DirectIn = false
|
conn.DirectIn = false
|
||||||
reader = buf.NewReadVReader(conn.Connection, rawConn)
|
reader = buf.NewReadVReader(conn.Connection, rawConn)
|
||||||
|
ct = counter
|
||||||
if conn.SHOW {
|
if conn.SHOW {
|
||||||
fmt.Println(conn.MARK, "ReadV")
|
fmt.Println(conn.MARK, "ReadV")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer, err := reader.ReadMultiBuffer()
|
buffer, err := reader.ReadMultiBuffer()
|
||||||
if !buffer.IsEmpty() {
|
if !buffer.IsEmpty() {
|
||||||
|
if ct != nil {
|
||||||
|
ct.Add(int64(buffer.Len()))
|
||||||
|
}
|
||||||
timer.Update()
|
timer.Update()
|
||||||
if werr := writer.WriteMultiBuffer(buffer); werr != nil {
|
if werr := writer.WriteMultiBuffer(buffer); werr != nil {
|
||||||
return werr
|
return werr
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
feature_inbound "v2ray.com/core/features/inbound"
|
feature_inbound "v2ray.com/core/features/inbound"
|
||||||
"v2ray.com/core/features/policy"
|
"v2ray.com/core/features/policy"
|
||||||
"v2ray.com/core/features/routing"
|
"v2ray.com/core/features/routing"
|
||||||
|
"v2ray.com/core/features/stats"
|
||||||
"v2ray.com/core/proxy/vless"
|
"v2ray.com/core/proxy/vless"
|
||||||
"v2ray.com/core/proxy/vless/encoding"
|
"v2ray.com/core/proxy/vless/encoding"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
@ -145,8 +146,10 @@ func (*Handler) Network() []net.Network {
|
|||||||
// Process implements proxy.Inbound.Process().
|
// Process implements proxy.Inbound.Process().
|
||||||
func (h *Handler) Process(ctx context.Context, network net.Network, connection internet.Connection, dispatcher routing.Dispatcher) error {
|
func (h *Handler) Process(ctx context.Context, network net.Network, connection internet.Connection, dispatcher routing.Dispatcher) error {
|
||||||
sid := session.ExportIDToError(ctx)
|
sid := session.ExportIDToError(ctx)
|
||||||
|
|
||||||
iConn := connection
|
iConn := connection
|
||||||
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
|
statConn, ok := iConn.(*internet.StatCouterConnection)
|
||||||
|
if ok {
|
||||||
iConn = statConn.Connection
|
iConn = statConn.Connection
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +441,11 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if rawConn != nil {
|
if rawConn != nil {
|
||||||
err = encoding.ReadV(clientReader, serverWriter, timer, iConn.(*xtls.Conn), rawConn)
|
var counter stats.Counter
|
||||||
|
if statConn != nil {
|
||||||
|
counter = statConn.ReadCounter
|
||||||
|
}
|
||||||
|
err = encoding.ReadV(clientReader, serverWriter, timer, iConn.(*xtls.Conn), rawConn, counter)
|
||||||
} else {
|
} else {
|
||||||
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
// from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer
|
||||||
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
|
err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer))
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"v2ray.com/core/common/signal"
|
"v2ray.com/core/common/signal"
|
||||||
"v2ray.com/core/common/task"
|
"v2ray.com/core/common/task"
|
||||||
"v2ray.com/core/features/policy"
|
"v2ray.com/core/features/policy"
|
||||||
|
"v2ray.com/core/features/stats"
|
||||||
"v2ray.com/core/proxy/vless"
|
"v2ray.com/core/proxy/vless"
|
||||||
"v2ray.com/core/proxy/vless/encoding"
|
"v2ray.com/core/proxy/vless/encoding"
|
||||||
"v2ray.com/core/transport"
|
"v2ray.com/core/transport"
|
||||||
@ -91,7 +92,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
iConn := conn
|
iConn := conn
|
||||||
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
|
statConn, ok := iConn.(*internet.StatCouterConnection)
|
||||||
|
if ok {
|
||||||
iConn = statConn.Connection
|
iConn = statConn.Connection
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +215,11 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
serverReader := encoding.DecodeBodyAddons(conn, request, responseAddons)
|
serverReader := encoding.DecodeBodyAddons(conn, request, responseAddons)
|
||||||
|
|
||||||
if rawConn != nil {
|
if rawConn != nil {
|
||||||
err = encoding.ReadV(serverReader, clientWriter, timer, iConn.(*xtls.Conn), rawConn)
|
var counter stats.Counter
|
||||||
|
if statConn != nil {
|
||||||
|
counter = statConn.ReadCounter
|
||||||
|
}
|
||||||
|
err = encoding.ReadV(serverReader, clientWriter, timer, iConn.(*xtls.Conn), rawConn, counter)
|
||||||
} else {
|
} else {
|
||||||
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
// from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer
|
||||||
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer))
|
||||||
|
Loading…
Reference in New Issue
Block a user