Skip to content

Commit

Permalink
Renetcode: use timeout given for ConnectToken instead of fixed 15 secs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspoffo committed Jan 5, 2024
1 parent b873925 commit 9add0a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions renetcode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,4 @@ const NETCODE_CHALLENGE_TOKEN_BYTES: usize = 300;
const NETCODE_CONNECT_TOKEN_XNONCE_BYTES: usize = 24;

const NETCODE_ADDITIONAL_DATA_SIZE: usize = 13 + 8 + 8;

const NETCODE_TIMEOUT_SECONDS: i32 = 15;

const NETCODE_SEND_RATE: Duration = Duration::from_millis(250);
6 changes: 3 additions & 3 deletions renetcode/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
crypto::{dencrypted_in_place_xnonce, encrypt_in_place_xnonce, generate_random_bytes},
serialize::*,
NetcodeError, NETCODE_ADDITIONAL_DATA_SIZE, NETCODE_ADDRESS_IPV4, NETCODE_ADDRESS_IPV6, NETCODE_ADDRESS_NONE,
NETCODE_CONNECT_TOKEN_PRIVATE_BYTES, NETCODE_CONNECT_TOKEN_XNONCE_BYTES, NETCODE_KEY_BYTES, NETCODE_TIMEOUT_SECONDS,
NETCODE_USER_DATA_BYTES, NETCODE_VERSION_INFO,
NETCODE_CONNECT_TOKEN_PRIVATE_BYTES, NETCODE_CONNECT_TOKEN_XNONCE_BYTES, NETCODE_KEY_BYTES, NETCODE_USER_DATA_BYTES,
NETCODE_VERSION_INFO,
};
use chacha20poly1305::aead::Error as CryptoError;

Expand Down Expand Up @@ -114,7 +114,7 @@ impl ConnectToken {
server_addresses: private_connect_token.server_addresses,
client_to_server_key: private_connect_token.client_to_server_key,
server_to_client_key: private_connect_token.server_to_client_key,
timeout_seconds: NETCODE_TIMEOUT_SECONDS,
timeout_seconds,
})
}

Expand Down

3 comments on commit 9add0a3

@UkoeHB
Copy link
Contributor

@UkoeHB UkoeHB commented on 9add0a3 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this uses the same timeout on the server and client, is that recommended by the netcode spec?

@lucaspoffo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this uses the same timeout on the server and client, is that recommended by the netcode spec?

Yeah, it uses the timeout from the connect token, this is what the c impl does:

https://github.com/mas-bandwidth/netcode/blob/8a9df4116510b1b6214e297fca4fce298da04d05/netcode.c#L3309

@UkoeHB
Copy link
Contributor

@UkoeHB UkoeHB commented on 9add0a3 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.