1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

fix(server): allow read more bytes in a single message

Fixes #1155
This commit is contained in:
wdvxdr 2021-11-13 15:16:23 +08:00
parent 2ed99b48f4
commit 530e2c24d2
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
2 changed files with 5 additions and 6 deletions

View File

@ -231,9 +231,6 @@ func cut(s, sep string) (before, after string, found bool) {
return s, "", false return s, "", false
} }
func isASCIIDigit(c byte) bool { return '0' <= c && c <= '9' }
func isASCIILower(c byte) bool { return 'a' <= c && c <= 'z' }
// some abbreviations need translation before transforming ro snake case // some abbreviations need translation before transforming ro snake case
var replacer = strings.NewReplacer("ID", "Id") var replacer = strings.NewReplacer("ID", "Id")
@ -241,11 +238,12 @@ func snakecase(s string) string {
s = replacer.Replace(s) s = replacer.Replace(s)
t := make([]byte, 0, 32) t := make([]byte, 0, 32)
for i := 0; i < len(s); i++ { for i := 0; i < len(s); i++ {
if isASCIILower(s[i]) || isASCIIDigit(s[i]) { c := s[i]
t = append(t, s[i]) if ('a' <= c && c <= 'z') || ('0' <= c && c <= '9') {
t = append(t, c)
} else { } else {
t = append(t, '_') t = append(t, '_')
t = append(t, s[i]^0x20) t = append(t, c^0x20)
} }
} }
return string(t) return string(t)

View File

@ -167,6 +167,7 @@ func (c *websocketClient) connect(typ, url string, conptr **wsConn) {
func (c *websocketClient) listenAPI(conn *wsConn, u bool) { func (c *websocketClient) listenAPI(conn *wsConn, u bool) {
defer func() { _ = conn.Close(websocket.StatusNormalClosure, "") }() defer func() { _ = conn.Close(websocket.StatusNormalClosure, "") }()
conn.Conn.SetReadLimit(1024 * 1024 * 128)
for { for {
buffer := global.NewBuffer() buffer := global.NewBuffer()
t, reader, err := conn.Conn.Reader(context.Background()) t, reader, err := conn.Conn.Reader(context.Background())