Ver Fonte

handle status keep alive

Darien Raymond há 8 anos atrás
pai
commit
9b834a2148
2 ficheiros alterados com 24 adições e 3 exclusões
  1. 4 3
      app/proxyman/mux/frame.go
  2. 20 0
      app/proxyman/mux/mux.go

+ 4 - 3
app/proxyman/mux/frame.go

@@ -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

+ 20 - 0
app/proxyman/mux/mux.go

@@ -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()