Browse Source

Fix chat messages not arriving at the MT server

master
HimbeerserverDE 1 year ago
parent
commit
2b8d7ed330
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
  1. 10
      chat.go
  2. 2
      command.go
  3. 2
      console.go

10
chat.go

@ -56,11 +56,11 @@ func RegisterOnServerChatMessage(function func(*Conn, string) bool) {
onServerChatMsg = append(onServerChatMsg, function)
}
func processChatMessage(c *Conn, pkt rudp.Pkt) bool {
r := ByteReader(pkt)
func processChatMessage(c *Conn, r *bytes.Reader) bool {
r.Seek(2, io.SeekCurrent)
wstr := make([]byte, r.Len()-4)
r.ReadAt(wstr, 4)
wstr := make([]byte, r.Len())
r.Read(wstr)
s := string(narrow(wstr))
if strings.HasPrefix(s, ChatCommandPrefix) {
@ -68,6 +68,8 @@ func processChatMessage(c *Conn, pkt rudp.Pkt) bool {
s = strings.Replace(s, ChatCommandPrefix, "", 1)
params := strings.Split(s, " ")
log.Print(c.Username(), " issued command: ", s)
// Priv check
allow, err := c.CheckPrivs(chatCommands[params[0]].privs)
if err != nil {

2
command.go

@ -317,7 +317,7 @@ func processPktCommand(src, dst *Conn, pkt *rudp.Pkt) bool {
} else {
switch cmd := binary.BigEndian.Uint16(cmdBytes); cmd {
case ToServerChatMessage:
return processChatMessage(src, *pkt)
return processChatMessage(src, r)
case ToServerFirstSRP:
if src.sudoMode {
src.sudoMode = false

2
console.go

@ -128,7 +128,7 @@ func initCurses(l *Logger) {
consoleInput = []rune{}
if chatCommands[params[0]].function == nil {
log.Print("Unknown command " + params[0] + ".")
log.Print("Unknown command ", params[0])
continue
}

Loading…
Cancel
Save