go-a2s icon indicating copy to clipboard operation
go-a2s copied to clipboard

Index out of range error on `QueryRules`

Open wrefgtzweve opened this issue 1 year ago • 0 comments

Might be related to https://github.com/rumblefrog/go-a2s/issues/8

Getting this error when i try to query rules on some Gmod servers:

panic: runtime error: index out of range [3] with length 1

goroutine 699 [running]:
encoding/binary.littleEndian.Uint32(...)
        C:/Program Files/Go/src/encoding/binary/binary.go:64
github.com/rumblefrog/go-a2s.(*PacketReader).ReadUint32(...)
        C:/Users/XXXX/go/pkg/mod/github.com/rumblefrog/[email protected]/packet.go:89
github.com/rumblefrog/go-a2s.(*Client).getChallenge(0x17d2a90c328?, {0xc000425a30?, 0xc000b75c98?, 0xc0013f6930?}, 0x45)
        C:/Users/XXXX/go/pkg/mod/github.com/rumblefrog/[email protected]/challenge.go:28 +0x1d5
github.com/rumblefrog/go-a2s.(*Client).QueryRules(0xc0003dec60?)
        C:/Users/XXXX/go/pkg/mod/github.com/rumblefrog/[email protected]/rules.go:47 +0x54
main.fetchServer({{0xc0003dec60, 0x15}, 0x698c, {0xc0003dec78, 0x11}, {0xc0003dc540, 0x3d}, 0xfa0, {0xc0003dbe80, 0x9}, ...})
        C:/project/main.go:55 +0x8f
main.main.func1()
        C:/project/main.go:102 +0xd8
created by main.main
        C:/project/main.go:91 +0x3a5
exit status 2

Code:

	client, err := a2s.NewClient(server.Addr)
	if err != nil {
		return
	}

	defer client.Close()
	rules, err := client.QueryRules()
	if err != nil {
		return
	}

wrefgtzweve avatar Jun 30 '23 14:06 wrefgtzweve