change the type of Connection ID to byte slice

This commit is contained in:
Marten Seemann
2018-03-16 13:29:47 +01:00
parent af8971d8c9
commit 1a035a265c
28 changed files with 258 additions and 189 deletions

View File

@@ -308,7 +308,7 @@ func (c *client) handlePacket(remoteAddr net.Addr, packet []byte) {
defer c.mutex.Unlock()
// reject packets with the wrong connection ID
if !hdr.OmitConnectionID && hdr.ConnectionID != c.connectionID {
if !hdr.OmitConnectionID && !hdr.ConnectionID.Equal(c.connectionID) {
return
}
@@ -316,7 +316,7 @@ func (c *client) handlePacket(remoteAddr net.Addr, packet []byte) {
cr := c.conn.RemoteAddr()
// check if the remote address and the connection ID match
// otherwise this might be an attacker trying to inject a PUBLIC_RESET to kill the connection
if cr.Network() != remoteAddr.Network() || cr.String() != remoteAddr.String() || hdr.ConnectionID != c.connectionID {
if cr.Network() != remoteAddr.Network() || cr.String() != remoteAddr.String() || !hdr.ConnectionID.Equal(c.connectionID) {
c.logger.Infof("Received a spoofed Public Reset. Ignoring.")
return
}