mirror of https://github.com/v2ray/v2ray-core
handle status keep alive
parent
8800238d24
commit
9b834a2148
|
@ -9,9 +9,10 @@ import (
|
||||||
type SessionStatus byte
|
type SessionStatus byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SessionStatusNew SessionStatus = 0x01
|
SessionStatusNew SessionStatus = 0x01
|
||||||
SessionStatusKeep SessionStatus = 0x02
|
SessionStatusKeep SessionStatus = 0x02
|
||||||
SessionStatusEnd SessionStatus = 0x03
|
SessionStatusEnd SessionStatus = 0x03
|
||||||
|
SessionStatusKeepAlive SessionStatus = 0x04
|
||||||
)
|
)
|
||||||
|
|
||||||
type Option byte
|
type Option byte
|
||||||
|
|
|
@ -295,6 +295,16 @@ func (m *Client) fetchOutput() {
|
||||||
log.Trace(newError("failed to read metadata").Base(err))
|
log.Trace(newError("failed to read metadata").Base(err))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if meta.SessionStatus == SessionStatusKeepAlive {
|
||||||
|
if meta.Option.Has(OptionData) {
|
||||||
|
if err := drain(reader); err != nil {
|
||||||
|
log.Trace(newError("failed to read data").Base(err))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
m.access.RLock()
|
m.access.RLock()
|
||||||
s, found := m.sessions[meta.SessionID]
|
s, found := m.sessions[meta.SessionID]
|
||||||
m.access.RUnlock()
|
m.access.RUnlock()
|
||||||
|
@ -390,6 +400,16 @@ func (w *ServerWorker) run(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if meta.SessionStatus == SessionStatusKeepAlive {
|
||||||
|
if meta.Option.Has(OptionData) {
|
||||||
|
if err := drain(reader); err != nil {
|
||||||
|
log.Trace(newError("failed to read data").Base(err))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
w.access.RLock()
|
w.access.RLock()
|
||||||
s, found := w.sessions[meta.SessionID]
|
s, found := w.sessions[meta.SessionID]
|
||||||
w.access.RUnlock()
|
w.access.RUnlock()
|
||||||
|
|
Loading…
Reference in New Issue