mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Add checks for buggy goprotobuf.
This commit is contained in:
parent
3529993601
commit
a1bd184e50
1 changed files with 18 additions and 0 deletions
18
grumble.go
18
grumble.go
|
|
@ -8,6 +8,9 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"log"
|
||||
"mumbleproto"
|
||||
"goprotobuf.googlecode.com/hg/proto"
|
||||
)
|
||||
|
||||
var help *bool = flag.Bool("help", false, "Show this help")
|
||||
|
|
@ -19,6 +22,19 @@ func usage() {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
// Check that we're using a version of goprotobuf that is able to
|
||||
// correctly encode empty byte slices.
|
||||
func checkProtoLib() {
|
||||
us := &mumbleproto.UserState{}
|
||||
us.Texture = []byte{}
|
||||
d, _ := proto.Marshal(us)
|
||||
nus := &mumbleproto.UserState{}
|
||||
proto.Unmarshal(d, nus)
|
||||
if nus.Texture == nil {
|
||||
log.Exitf("Unpatched version of goprotobuf. Grumble is refusing to run.")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if *help == true {
|
||||
|
|
@ -26,6 +42,8 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
checkProtoLib()
|
||||
|
||||
// Create our default server
|
||||
m, err := NewServer(*host, *port)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue