mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-28 16:09:48 +00:00
feat(client,mux): Improve stream readiness detection and add safe buffer access
This commit is contained in:
@@ -218,10 +218,11 @@ func (c *Client) handleSOCKS5(conn net.Conn) {
|
||||
defer timeout.Stop()
|
||||
|
||||
go func() {
|
||||
for i := 0; i < 100; i++ {
|
||||
for i := 0; i < 200; i++ {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
data := c.mux.ReadStream(sid)
|
||||
if len(data) > 0 {
|
||||
|
||||
stream := c.mux.GetStream(sid)
|
||||
if stream != nil && len(stream.RecvBuf()) > 0 {
|
||||
connected <- true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@ type Stream struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *Stream) RecvBuf() []byte {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.recvBuf
|
||||
}
|
||||
|
||||
type Multiplexer struct {
|
||||
streams map[uint16]*Stream
|
||||
nextID uint16
|
||||
|
||||
Reference in New Issue
Block a user