mirror of
https://github.com/cbeuw/Cloak.git
synced 2024-11-05 21:20:45 +00:00
Use constants for Closing value
This commit is contained in:
parent
c26be98e79
commit
fbee919f47
@ -1,5 +1,11 @@
|
|||||||
package multiplex
|
package multiplex
|
||||||
|
|
||||||
|
const (
|
||||||
|
C_NOOP = iota
|
||||||
|
C_STREAM
|
||||||
|
C_SESSION
|
||||||
|
)
|
||||||
|
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
StreamID uint32
|
StreamID uint32
|
||||||
Seq uint64
|
Seq uint64
|
||||||
|
@ -144,7 +144,7 @@ func (sesh *Session) closeStream(s *Stream, active bool) error {
|
|||||||
f := &Frame{
|
f := &Frame{
|
||||||
StreamID: s.id,
|
StreamID: s.id,
|
||||||
Seq: atomic.AddUint64(&s.nextSendSeq, 1) - 1,
|
Seq: atomic.AddUint64(&s.nextSendSeq, 1) - 1,
|
||||||
Closing: 1,
|
Closing: C_STREAM,
|
||||||
Payload: pad,
|
Payload: pad,
|
||||||
}
|
}
|
||||||
i, err := s.session.Obfs(f, s.obfsBuf)
|
i, err := s.session.Obfs(f, s.obfsBuf)
|
||||||
@ -185,10 +185,10 @@ func (sesh *Session) recvDataFromRemote(data []byte) error {
|
|||||||
stream := streamI.(*Stream)
|
stream := streamI.(*Stream)
|
||||||
return stream.writeFrame(*frame)
|
return stream.writeFrame(*frame)
|
||||||
} else {
|
} else {
|
||||||
if frame.Closing == 1 {
|
if frame.Closing == C_STREAM {
|
||||||
// If the stream has been closed and the current frame is a closing frame, we do noop
|
// If the stream has been closed and the current frame is a closing frame, we do noop
|
||||||
return nil
|
return nil
|
||||||
} else if frame.Closing == 2 {
|
} else if frame.Closing == C_SESSION {
|
||||||
// Closing session
|
// Closing session
|
||||||
sesh.SetTerminalMsg("Received a closing notification frame")
|
sesh.SetTerminalMsg("Received a closing notification frame")
|
||||||
return sesh.passiveClose()
|
return sesh.passiveClose()
|
||||||
@ -268,7 +268,7 @@ func (sesh *Session) Close() error {
|
|||||||
f := &Frame{
|
f := &Frame{
|
||||||
StreamID: 0xffffffff,
|
StreamID: 0xffffffff,
|
||||||
Seq: 0,
|
Seq: 0,
|
||||||
Closing: 2,
|
Closing: C_SESSION,
|
||||||
Payload: pad,
|
Payload: pad,
|
||||||
}
|
}
|
||||||
obfsBuf := make([]byte, len(pad)+64)
|
obfsBuf := make([]byte, len(pad)+64)
|
||||||
|
Loading…
Reference in New Issue
Block a user