Support for encrypted net-messages 🥳
This means we can now read chat messages from Valve Matchmaking demos! (and more!)
Main PR: #323
New Features
- Added
MatchInfoDecryptionKey()
func to get the decryption key from the contents of amatch730_*.dem.info
file - Added
ParserConfig.NetMessageDecryptionKey
to set the decryption key to use for the parser
Example
package main
import (
"io/ioutil"
"log"
"os"
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
)
func checkErr(err error) {
if err != nil {
panic(err)
}
}
func main() {
infoF, err := os.Open("test/cs-demos/match730_003528806449641685104_1453182610_271.dem.info")
checkErr(err)
b, err := ioutil.ReadAll(infoF)
checkErr(err)
k, err := dem.MatchInfoDecryptionKey(b)
checkErr(err)
f, err := os.Open("test/cs-demos/match730_003528806449641685104_1453182610_271.dem")
checkErr(err)
defer f.Close()
cfg := dem.DefaultParserConfig
cfg.NetMessageDecryptionKey = k
p := dem.NewParserWithConfig(f, cfg)
p.RegisterEventHandler(func(message events.ChatMessage) {
log.Println(message)
})
err = p.ParseToEnd()
checkErr(err)
}