1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-05 09:47:56 -05:00

handle status keep alive

This commit is contained in:
Darien Raymond 2017-04-12 11:52:10 +02:00
parent 8800238d24
commit 9b834a2148
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 24 additions and 3 deletions

View File

@ -9,9 +9,10 @@ import (
type SessionStatus byte
const (
SessionStatusNew SessionStatus = 0x01
SessionStatusKeep SessionStatus = 0x02
SessionStatusEnd SessionStatus = 0x03
SessionStatusNew SessionStatus = 0x01
SessionStatusKeep SessionStatus = 0x02
SessionStatusEnd SessionStatus = 0x03
SessionStatusKeepAlive SessionStatus = 0x04
)
type Option byte

View File

@ -295,6 +295,16 @@ func (m *Client) fetchOutput() {
log.Trace(newError("failed to read metadata").Base(err))
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()
s, found := m.sessions[meta.SessionID]
m.access.RUnlock()
@ -390,6 +400,16 @@ func (w *ServerWorker) run(ctx context.Context) {
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()
s, found := w.sessions[meta.SessionID]
w.access.RUnlock()