mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-17 17:48:40 +00:00
Add proxy Scheduler
This commit is contained in:
parent
bb2900d676
commit
76d7609051
2 changed files with 86 additions and 3 deletions
|
@ -183,7 +183,7 @@ func NewTrafficState(userUUID []byte, flow string) *TrafficState {
|
|||
return &state
|
||||
}
|
||||
|
||||
// VisionReader is used to read xtls vision protocol
|
||||
// VisionReader is used to read seed protocol
|
||||
// Note Vision probably only make sense as the inner most layer of reader, since it need assess traffic state from origin proxy traffic
|
||||
type VisionReader struct {
|
||||
buf.Reader
|
||||
|
@ -257,7 +257,7 @@ func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
|||
return buffer, err
|
||||
}
|
||||
|
||||
// VisionWriter is used to write xtls vision protocol
|
||||
// VisionWriter is used to write seed protocol
|
||||
// Note Vision probably only make sense as the inner most layer of writer, since it need assess traffic state from origin proxy traffic
|
||||
type VisionWriter struct {
|
||||
buf.Writer
|
||||
|
@ -266,6 +266,7 @@ type VisionWriter struct {
|
|||
ctx context.Context
|
||||
writeOnceUserUUID []byte
|
||||
isUplink bool
|
||||
scheduler *Scheduler
|
||||
}
|
||||
|
||||
func NewVisionWriter(writer buf.Writer, addon *Addons, state *TrafficState, isUplink bool, context context.Context) *VisionWriter {
|
||||
|
@ -278,6 +279,7 @@ func NewVisionWriter(writer buf.Writer, addon *Addons, state *TrafficState, isUp
|
|||
ctx: context,
|
||||
writeOnceUserUUID: w,
|
||||
isUplink: isUplink,
|
||||
scheduler: NewScheduler(writer, addon, state, context),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +341,14 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
|||
if w.trafficState.StartTime.IsZero() {
|
||||
w.trafficState.StartTime = time.Now()
|
||||
}
|
||||
return w.Writer.WriteMultiBuffer(mb)
|
||||
w.scheduler.Buffer <- mb
|
||||
if w.addons.Scheduler == nil {
|
||||
w.scheduler.Trigger <- -1 // send all buffers
|
||||
}
|
||||
if len(w.scheduler.Error) > 0 {
|
||||
return <-w.scheduler.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReshapeMultiBuffer prepare multi buffer for padding structure (max 21 bytes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue