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"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"log"
|
||||||
|
"mumbleproto"
|
||||||
|
"goprotobuf.googlecode.com/hg/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var help *bool = flag.Bool("help", false, "Show this help")
|
var help *bool = flag.Bool("help", false, "Show this help")
|
||||||
|
|
@ -19,6 +22,19 @@ func usage() {
|
||||||
flag.PrintDefaults()
|
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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *help == true {
|
if *help == true {
|
||||||
|
|
@ -26,6 +42,8 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkProtoLib()
|
||||||
|
|
||||||
// Create our default server
|
// Create our default server
|
||||||
m, err := NewServer(*host, *port)
|
m, err := NewServer(*host, *port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue