udp: Fix minor protocol errors, announces working

This commit is contained in:
Justin Li 2015-02-20 11:44:05 -05:00
parent 22e83739c9
commit abd2b5ade4
2 changed files with 9 additions and 2 deletions

View file

@ -48,3 +48,7 @@ func GenerateConnectionID(ip []byte) []byte {
return ct[:8]
}
func init() {
InitConnectionIDEncryption()
}

View file

@ -14,9 +14,9 @@ import (
"github.com/chihaya/chihaya/tracker/models"
)
var initialConnectionID = []byte{0x04, 0x17, 0x27, 0x10, 0x19, 0x80}
var initialConnectionID = []byte{0, 0, 0x04, 0x17, 0x27, 0x10, 0x19, 0x80}
var eventIDs = []string{"none", "completed", "started", "stopped"}
var eventIDs = []string{"", "completed", "started", "stopped"}
var (
errMalformedPacket = errors.New("malformed packet")
@ -110,6 +110,9 @@ func (s *Server) newAnnounce(packet []byte, ip net.IP) (*models.Announce, error)
if ip == nil {
return nil, errMalformedIP
}
if ipv4 := ip.To4(); ipv4 != nil {
ip = ipv4
}
// TODO(pushrax): what exactly is the key "key" used for?