tcpmux: support authentication (#3345)

This commit is contained in:
fatedier
2023-03-07 19:53:32 +08:00
committed by GitHub
parent 54eb704650
commit 862b1642ba
11 changed files with 324 additions and 71 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
)
@@ -22,6 +23,9 @@ func ReadBytes(r io.Reader) ([]byte, error) {
if err := binary.Read(r, binary.BigEndian, &length); err != nil {
return nil, err
}
if length < 0 || length > 10*1024*1024 {
return nil, fmt.Errorf("invalid length")
}
buffer := make([]byte, length)
n, err := io.ReadFull(r, buffer)
if err != nil {