mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-04-24 15:37:58 -05:00
Fix short version 3 match reservation
This commit is contained in:
parent
53cec11f17
commit
fb25e4bcc1
|
|
@ -49,6 +49,7 @@ type MatchCommandData struct {
|
|||
|
||||
type MatchCommandDataReservation struct {
|
||||
MatchType byte
|
||||
HasPublicIP bool
|
||||
PublicIP uint32
|
||||
PublicPort uint16
|
||||
LocalIP uint32
|
||||
|
|
@ -174,7 +175,11 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
|||
|
||||
switch command {
|
||||
case MatchReservation:
|
||||
if (version == 3 && len(buffer) != 0xC) || (version == 11 && len(buffer) != 0x14) || (version == 90 && len(buffer) != 0x24) {
|
||||
if version == 3 && (len(buffer) != 0x04 && len(buffer) != 0x0C) {
|
||||
break
|
||||
}
|
||||
|
||||
if (version == 11 && len(buffer) != 0x14) || (version == 90 && len(buffer) != 0x24) {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +188,13 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
|||
break
|
||||
}
|
||||
|
||||
if version == 3 && len(buffer) == 0x04 {
|
||||
return MatchCommandData{Reservation: &MatchCommandDataReservation{
|
||||
MatchType: byte(matchType),
|
||||
HasPublicIP: false,
|
||||
}}, true
|
||||
}
|
||||
|
||||
publicPort := binary.LittleEndian.Uint32(buffer[0x08:0x0C])
|
||||
if publicPort > 0xffff {
|
||||
break
|
||||
|
|
@ -191,9 +203,10 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
|||
switch version {
|
||||
case 3:
|
||||
return MatchCommandData{Reservation: &MatchCommandDataReservation{
|
||||
MatchType: byte(matchType),
|
||||
PublicIP: binary.BigEndian.Uint32(buffer[0x04:0x08]),
|
||||
PublicPort: uint16(publicPort),
|
||||
MatchType: byte(matchType),
|
||||
HasPublicIP: true,
|
||||
PublicIP: binary.BigEndian.Uint32(buffer[0x04:0x08]),
|
||||
PublicPort: uint16(publicPort),
|
||||
}}, true
|
||||
|
||||
case 11:
|
||||
|
|
@ -205,6 +218,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
|||
|
||||
return MatchCommandData{Reservation: &MatchCommandDataReservation{
|
||||
MatchType: byte(matchType),
|
||||
HasPublicIP: true,
|
||||
PublicIP: binary.BigEndian.Uint32(buffer[0x04:0x08]),
|
||||
PublicPort: uint16(publicPort),
|
||||
IsFriend: isFriend,
|
||||
|
|
@ -225,6 +239,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
|||
|
||||
return MatchCommandData{Reservation: &MatchCommandDataReservation{
|
||||
MatchType: byte(matchType),
|
||||
HasPublicIP: true,
|
||||
PublicIP: binary.BigEndian.Uint32(buffer[0x04:0x08]),
|
||||
PublicPort: uint16(publicPort),
|
||||
LocalIP: binary.BigEndian.Uint32(buffer[0x0C:0x10]),
|
||||
|
|
@ -423,6 +438,11 @@ func EncodeMatchCommand(command byte, data MatchCommandData, version int) ([]byt
|
|||
switch command {
|
||||
case MatchReservation:
|
||||
message := binary.LittleEndian.AppendUint32([]byte{}, uint32(data.Reservation.MatchType))
|
||||
|
||||
if version == 3 && !data.Reservation.HasPublicIP {
|
||||
return message, true
|
||||
}
|
||||
|
||||
message = binary.BigEndian.AppendUint32(message, data.Reservation.PublicIP)
|
||||
message = binary.LittleEndian.AppendUint32(message, uint32(data.Reservation.PublicPort))
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ func SendClientMessage(senderIP string, destSearchID uint64, message []byte) {
|
|||
|
||||
if senderIPInt != int32(qr2IP) {
|
||||
logging.Error(moduleName, "Wrong QR2 IP in match command packet header")
|
||||
return
|
||||
}
|
||||
|
||||
sender = sessionByPublicIP[(uint64(qr2Port)<<32)|uint64(qr2IP)]
|
||||
|
|
@ -113,14 +114,16 @@ func SendClientMessage(senderIP string, destSearchID uint64, message []byte) {
|
|||
return
|
||||
}
|
||||
|
||||
if qr2IP != matchData.Reservation.PublicIP {
|
||||
logging.Error(moduleName, "RESERVATION: Public IP mismatch in header and command")
|
||||
return
|
||||
}
|
||||
if matchData.Reservation.HasPublicIP {
|
||||
if qr2IP != matchData.Reservation.PublicIP {
|
||||
logging.Error(moduleName, "RESERVATION: Public IP mismatch in header and command")
|
||||
return
|
||||
}
|
||||
|
||||
if qr2Port != matchData.Reservation.PublicPort {
|
||||
logging.Error(moduleName, "RESERVATION: Public port mismatch in header and command")
|
||||
return
|
||||
if qr2Port != matchData.Reservation.PublicPort {
|
||||
logging.Error(moduleName, "RESERVATION: Public port mismatch in header and command")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if version == 90 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user