mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Enable splice for freedom outbound (downlink only)
- Add outbound name - Add outbound conn in ctx - Refactor splice: it can be turn on from all inbounds and outbounds - Refactor splice: Add splice copy to vless inbound - Fix http error test - Add freedom splice toggle via env var - Populate outbound obj in context - Use CanSpliceCopy to mark a connection - Turn off splice by default
This commit is contained in:
parent
ae2fa30e01
commit
efd32b0fb2
32 changed files with 282 additions and 168 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/common/signal"
|
||||
"github.com/xtls/xray-core/features/stats"
|
||||
)
|
||||
|
||||
type dataHandler func(MultiBuffer)
|
||||
|
@ -40,6 +41,17 @@ func CountSize(sc *SizeCounter) CopyOption {
|
|||
}
|
||||
}
|
||||
|
||||
// AddToStatCounter a CopyOption add to stat counter
|
||||
func AddToStatCounter(sc stats.Counter) CopyOption {
|
||||
return func(handler *copyHandler) {
|
||||
handler.onData = append(handler.onData, func(b MultiBuffer) {
|
||||
if sc != nil {
|
||||
sc.Add(int64(b.Len()))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type readError struct {
|
||||
error
|
||||
}
|
||||
|
|
|
@ -50,6 +50,16 @@ type Inbound struct {
|
|||
Conn net.Conn
|
||||
// Timer of the inbound buf copier. May be nil.
|
||||
Timer *signal.ActivityTimer
|
||||
// CanSpliceCopy is a property for this connection, set by both inbound and outbound
|
||||
// 1 = can, 2 = after processing protocol info should be able to, 3 = cannot
|
||||
CanSpliceCopy int
|
||||
}
|
||||
|
||||
func(i *Inbound) SetCanSpliceCopy(canSpliceCopy int) int {
|
||||
if canSpliceCopy > i.CanSpliceCopy {
|
||||
i.CanSpliceCopy = canSpliceCopy
|
||||
}
|
||||
return i.CanSpliceCopy
|
||||
}
|
||||
|
||||
// Outbound is the metadata of an outbound connection.
|
||||
|
@ -60,6 +70,10 @@ type Outbound struct {
|
|||
RouteTarget net.Destination
|
||||
// Gateway address
|
||||
Gateway net.Address
|
||||
// Name of the outbound proxy that handles the connection.
|
||||
Name string
|
||||
// Conn is actually internet.Connection. May be nil. It is currently nil for outbound with proxySettings
|
||||
Conn net.Conn
|
||||
}
|
||||
|
||||
// SniffingRequest controls the behavior of content sniffing.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue