Skip to content

Commit

Permalink
handler.go: Send NewIncomingConnection before any user packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed May 2, 2024
1 parent e8e7d67 commit 949ddbd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (dialer Dialer) clientListen(rakConn *Conn, conn net.Conn) {
continue
}
if err := rakConn.receive(b[:n]); err != nil {
dialer.ErrorLog.Error("client: handle packet: " + err.Error())
dialer.ErrorLog.Error("client: " + err.Error())
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ func handleConnectionRequestAccepted(conn *Conn, b []byte) error {
if err := pk.UnmarshalBinary(b); err != nil {
return fmt.Errorf("read CONNECTION_REQUEST_ACCEPTED: %w", err)
}

select {
case <-conn.connected:
return errUnexpectedAdditionalCRA
default:
// Make sure to send NewIncomingConnection before closing conn.connected.
err := conn.send(&message.NewIncomingConnection{ServerAddress: resolve(conn.raddr), RequestTimestamp: pk.AcceptedTimestamp, AcceptedTimestamp: timestamp()})
close(conn.connected)
return err
}
return conn.send(&message.NewIncomingConnection{ServerAddress: resolve(conn.raddr), RequestTimestamp: pk.RequestTimestamp, AcceptedTimestamp: pk.AcceptedTimestamp, SystemAddresses: pk.SystemAddresses})
}

// handleNewIncomingConnection handles an incoming connection packet from the
Expand Down
3 changes: 2 additions & 1 deletion packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ const (
type packet struct {
reliability byte

content []byte
messageIndex uint24
sequenceIndex uint24
orderIndex uint24

content []byte

split bool
splitCount uint32
splitIndex uint32
Expand Down

0 comments on commit 949ddbd

Please sign in to comment.