1
0
Fork 0
forked from External/grumble

grumble: fix cryptstate resync issues (and simplify Server.handleUdpPacket()).

This commit is contained in:
Mikkel Krautz 2013-05-23 23:31:30 +02:00
parent e72c8852d2
commit e6d4e0c453

View file

@ -975,14 +975,14 @@ func (server *Server) udpListenLoop() {
} }
} else { } else {
server.handleUdpPacket(udpaddr, buf, nread) server.handleUdpPacket(udpaddr, buf[0:nread])
} }
} }
} }
func (server *Server) handleUdpPacket(udpaddr *net.UDPAddr, buf []byte, nread int) { func (server *Server) handleUdpPacket(udpaddr *net.UDPAddr, buf []byte) {
var match *Client var match *Client
plain := make([]byte, nread) plain := make([]byte, len(buf))
// Determine which client sent the the packet. First, we // Determine which client sent the the packet. First, we
// check the map 'hpclients' in the server struct. It maps // check the map 'hpclients' in the server struct. It maps
@ -1004,7 +1004,7 @@ func (server *Server) handleUdpPacket(udpaddr *net.UDPAddr, buf []byte, nread in
host := udpaddr.IP.String() host := udpaddr.IP.String()
hostclients := server.hclients[host] hostclients := server.hclients[host]
for _, client := range hostclients { for _, client := range hostclients {
err := client.crypt.Decrypt(plain[0:], buf[0:nread]) err := client.crypt.Decrypt(plain[0:], buf)
if err != nil { if err != nil {
client.cryptResync() client.cryptResync()
return return