mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-03 12:27:58 +03:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b668333546 | ||
|
|
a22c4cf301 | ||
|
|
eba1f7258e | ||
|
|
33272a0499 |
+24
-6
@@ -18,6 +18,7 @@ type ActivityTimer struct {
|
|||||||
updated chan struct{}
|
updated chan struct{}
|
||||||
checkTask *task.Periodic
|
checkTask *task.Periodic
|
||||||
onTimeout func()
|
onTimeout func()
|
||||||
|
overridden bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ActivityTimer) Update() {
|
func (t *ActivityTimer) Update() {
|
||||||
@@ -31,14 +32,16 @@ func (t *ActivityTimer) check() error {
|
|||||||
select {
|
select {
|
||||||
case <-t.updated:
|
case <-t.updated:
|
||||||
default:
|
default:
|
||||||
t.finish()
|
t.finish(false)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ActivityTimer) finish() {
|
func (t *ActivityTimer) finish(locked bool) {
|
||||||
|
if !locked {
|
||||||
t.Lock()
|
t.Lock()
|
||||||
defer t.Unlock()
|
defer t.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
if t.onTimeout != nil {
|
if t.onTimeout != nil {
|
||||||
t.onTimeout()
|
t.onTimeout()
|
||||||
@@ -50,9 +53,12 @@ func (t *ActivityTimer) finish() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ActivityTimer) SetTimeout(timeout time.Duration) {
|
func (t *ActivityTimer) setTimeout(timeout time.Duration) {
|
||||||
|
if t.onTimeout == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if timeout == 0 {
|
if timeout == 0 {
|
||||||
t.finish()
|
t.finish(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,14 +67,26 @@ func (t *ActivityTimer) SetTimeout(timeout time.Duration) {
|
|||||||
Execute: t.check,
|
Execute: t.check,
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Lock()
|
|
||||||
|
|
||||||
if t.checkTask != nil {
|
if t.checkTask != nil {
|
||||||
t.checkTask.Close()
|
t.checkTask.Close()
|
||||||
|
t.overridden = true
|
||||||
}
|
}
|
||||||
t.checkTask = checkTask
|
t.checkTask = checkTask
|
||||||
t.Update()
|
t.Update()
|
||||||
common.Must(checkTask.Start())
|
common.Must(checkTask.Start())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *ActivityTimer) SetTimeout(timeout time.Duration) {
|
||||||
|
t.Lock()
|
||||||
|
t.setTimeout(timeout)
|
||||||
|
t.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *ActivityTimer) SetTimeoutIfNotOverridden(timeout time.Duration) {
|
||||||
|
t.Lock()
|
||||||
|
if !t.overridden {
|
||||||
|
t.setTimeout(timeout)
|
||||||
|
}
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ require (
|
|||||||
golang.org/x/sys v0.35.0
|
golang.org/x/sys v0.35.0
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
||||||
google.golang.org/grpc v1.75.0
|
google.golang.org/grpc v1.75.0
|
||||||
google.golang.org/protobuf v1.36.7
|
google.golang.org/protobuf v1.36.8
|
||||||
gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5
|
gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5
|
||||||
h12.io/socks v1.0.3
|
h12.io/socks v1.0.3
|
||||||
lukechampine.com/blake3 v1.4.1
|
lukechampine.com/blake3 v1.4.1
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:
|
|||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||||
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
|
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
|
||||||
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
||||||
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
|
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
|
||||||
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
|||||||
+2
-2
@@ -596,9 +596,9 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net
|
|||||||
statWriter, _ := writer.(*dispatcher.SizeStatWriter)
|
statWriter, _ := writer.(*dispatcher.SizeStatWriter)
|
||||||
//runtime.Gosched() // necessary
|
//runtime.Gosched() // necessary
|
||||||
time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice
|
time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice
|
||||||
timer.SetTimeout(8 * time.Hour) // prevent leak, just in case
|
timer.SetTimeoutIfNotOverridden(24 * time.Hour) // prevent leak, just in case
|
||||||
if inTimer != nil {
|
if inTimer != nil {
|
||||||
inTimer.SetTimeout(8 * time.Hour)
|
inTimer.SetTimeoutIfNotOverridden(24 * time.Hour)
|
||||||
}
|
}
|
||||||
w, err := tc.ReadFrom(readerConn)
|
w, err := tc.ReadFrom(readerConn)
|
||||||
if readCounter != nil {
|
if readCounter != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user