mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-27 21:05:53 +00:00
Merge branch 'master' into patch-4
This commit is contained in:
commit
bd1051b4c1
11 changed files with 96 additions and 39 deletions
|
@ -140,7 +140,14 @@ func (backend *backendInfo) SendRemoteCommand(remoteCommand, data string, auth A
|
|||
if resp.StatusCode == 401 {
|
||||
return "", ErrAuthorizationNeeded
|
||||
} else if resp.StatusCode < 200 || resp.StatusCode > 299 { // any non-2xx
|
||||
if resp.Header.Get("Content-Type") == "application/json" {
|
||||
// If the Content-Type header includes a charset, ignore it.
|
||||
typeStr := resp.Header.Get("Content-Type")
|
||||
splitIdx := strings.IndexRune(typeStr, ';')
|
||||
if ( splitIdx != -1 ) {
|
||||
typeStr = strings.TrimSpace(typeStr[0:splitIdx])
|
||||
}
|
||||
|
||||
if typeStr == "application/json" {
|
||||
var err2 ErrForwardedFromBackend
|
||||
err := json.Unmarshal(respBytes, &err2.JSONError)
|
||||
if err != nil {
|
||||
|
|
|
@ -108,31 +108,20 @@ func callHandler(handler CommandHandler, conn *websocket.Conn, client *ClientInf
|
|||
return handler(conn, client, cmsg)
|
||||
}
|
||||
|
||||
var DebugHello = ""
|
||||
|
||||
// C2SHello implements the `hello` C2S Command.
|
||||
// It calls SubscribeGlobal() and SubscribeDefaults() with the client, and fills out ClientInfo.Version and ClientInfo.ClientID.
|
||||
func C2SHello(_ *websocket.Conn, client *ClientInfo, msg ClientMessage) (_ ClientMessage, err error) {
|
||||
ary, ok := msg.Arguments.([]interface{})
|
||||
if !ok {
|
||||
if DebugHello != "" {
|
||||
fmt.Println("Hello error: was not an array:", ary)
|
||||
}
|
||||
err = ErrExpectedTwoStrings
|
||||
return
|
||||
}
|
||||
if len(ary) != 2 {
|
||||
if DebugHello != "" {
|
||||
fmt.Println("Hello error: array wrong length:", ary)
|
||||
}
|
||||
err = ErrExpectedTwoStrings
|
||||
return
|
||||
}
|
||||
version, ok := ary[0].(string)
|
||||
if !ok {
|
||||
if DebugHello != "" {
|
||||
fmt.Println("Hello error: version not a string:", ary)
|
||||
}
|
||||
err = ErrExpectedTwoStrings
|
||||
return
|
||||
}
|
||||
|
@ -149,9 +138,6 @@ func C2SHello(_ *websocket.Conn, client *ClientInfo, msg ClientMessage) (_ Clien
|
|||
} else if ary[1] == nil {
|
||||
clientID = uuid.NewV4()
|
||||
} else {
|
||||
if DebugHello != "" {
|
||||
fmt.Println("Hello error: client id not acceptable:", ary)
|
||||
}
|
||||
err = ErrExpectedTwoStrings
|
||||
return
|
||||
}
|
||||
|
|
|
@ -528,6 +528,7 @@ func UnmarshalClientMessage(data []byte, _ int, v interface{}) (err error) {
|
|||
if spaceIdx == -1 {
|
||||
out.Command = CommandPool.InternCommand(dataStr)
|
||||
out.Arguments = nil
|
||||
out.origArguments = ""
|
||||
return nil
|
||||
} else {
|
||||
out.Command = CommandPool.InternCommand(dataStr[:spaceIdx])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue