MCPcopy
hub / github.com/cbeuw/Cloak / MakeSession

Function MakeSession

internal/multiplex/session.go:90–123  ·  view source on GitHub ↗
(id uint32, config SessionConfig)

Source from the content-addressed store, hash-verified

88}
89
90func MakeSession(id uint32, config SessionConfig) *Session {
91 sesh := &Session{
92 id: id,
93 SessionConfig: config,
94 nextStreamID: 1,
95 acceptCh: make(chan *Stream, acceptBacklog),
96 recvFramePool: sync.Pool{New: func() interface{} { return &Frame{} }},
97 streams: map[uint32]*Stream{},
98 }
99 sesh.addrs.Store([]net.Addr{nil, nil})
100
101 if config.Valve == nil {
102 sesh.Valve = UNLIMITED_VALVE
103 }
104 if config.MsgOnWireSizeLimit <= 0 {
105 sesh.MsgOnWireSizeLimit = defaultMaxOnWireSize
106 }
107 if config.InactivityTimeout == 0 {
108 sesh.InactivityTimeout = defaultInactivityTimeout
109 }
110
111 sesh.maxStreamUnitWrite = sesh.MsgOnWireSizeLimit - frameHeaderLength - maxExtraLen
112 sesh.streamSendBufferSize = sesh.MsgOnWireSizeLimit
113 sesh.connReceiveBufferSize = 20480 // for backwards compatibility
114
115 sesh.streamObfsBufPool = sync.Pool{New: func() interface{} {
116 b := make([]byte, sesh.streamSendBufferSize)
117 return &b
118 }}
119
120 sesh.sb = makeSwitchboard(sesh)
121 time.AfterFunc(sesh.InactivityTimeout, sesh.checkTimeout)
122 return sesh
123}
124
125func (sesh *Session) GetSessionKey() [32]byte {
126 return sesh.sessionKey

Callers 15

TestSwitchboard_SendFunction · 0.70
TestSwitchboard_TxCreditFunction · 0.70
setupSesh_fuzzFunction · 0.70
makeSessionPairFunction · 0.70
TestRecvDataFromRemoteFunction · 0.70
TestParallelStreamsFunction · 0.70
TestSession_timeoutAfterFunction · 0.70

Calls 1

makeSwitchboardFunction · 0.85