Skip to content

Commit

Permalink
rename SIZE_OF_CONNECT_TOKEN to SIZE_OF_PADDED_CONNECT_TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-Bhatia-0 committed Mar 16, 2024
1 parent dd509a0 commit cafba60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions netcode/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const SIZE_OF_HMAC = 16

const SIZE_OF_ENCRYPTED_PRIVATE_CONNECT_TOKEN_DATA = 1024

const SIZE_OF_CONNECT_TOKEN = 2048
const SIZE_OF_PADDED_CONNECT_TOKEN = 2048

const ROOM_SIZE = 3

Expand Down Expand Up @@ -199,7 +199,7 @@ get_serialized_size(value::PaddedPrivateConnectToken) = SIZE_OF_ENCRYPTED_PRIVAT

get_serialized_size(value::PrivateConnectTokenAssociatedData) = get_serialized_size(value.connect_token.netcode_version_info) + get_serialized_size(value.connect_token.protocol_id) + get_serialized_size(value.connect_token.expire_timestamp)

get_serialized_size(value::PaddedConnectToken) = SIZE_OF_CONNECT_TOKEN
get_serialized_size(value::PaddedConnectToken) = SIZE_OF_PADDED_CONNECT_TOKEN

function get_serialized_size(value::PrivateConnectToken)
connect_token = value.connect_token
Expand Down Expand Up @@ -404,7 +404,7 @@ function Base.write(io::IO, padded_connect_token::PaddedConnectToken)
@assert n == get_serialized_size(connect_token)
@info "ConnectToken written: $(n) bytes"

for i in 1 : SIZE_OF_CONNECT_TOKEN - n
for i in 1 : SIZE_OF_PADDED_CONNECT_TOKEN - n
n += write(io, UInt8(0))
end

Expand Down Expand Up @@ -596,10 +596,10 @@ function auth_handler(request)
return HTTP.Response(400, "ERROR: Invalid credentials")
else
if bytes2hex(SHA.sha3_256(hashed_password * USER_DATA[i, :salt])) == USER_DATA[i, :hashed_salted_hashed_password]
io = IOBuffer(maxsize = SIZE_OF_CONNECT_TOKEN)
io = IOBuffer(maxsize = SIZE_OF_PADDED_CONNECT_TOKEN)

connect_token = ConnectToken(i)
@info "connect_token struct data" connect_token.netcode_version_info connect_token.protocol_id connect_token.create_timestamp connect_token.expire_timestamp connect_token.nonce connect_token.timeout_seconds connect_token.client_id connect_token.netcode_addresses connect_token.client_to_server_key connect_token.server_to_client_key connect_token.user_data SERVER_SIDE_SHARED_KEY SIZE_OF_HMAC SIZE_OF_ENCRYPTED_PRIVATE_CONNECT_TOKEN_DATA SIZE_OF_CONNECT_TOKEN
@info "connect_token struct data" connect_token.netcode_version_info connect_token.protocol_id connect_token.create_timestamp connect_token.expire_timestamp connect_token.nonce connect_token.timeout_seconds connect_token.client_id connect_token.netcode_addresses connect_token.client_to_server_key connect_token.server_to_client_key connect_token.user_data SERVER_SIDE_SHARED_KEY SIZE_OF_HMAC SIZE_OF_ENCRYPTED_PRIVATE_CONNECT_TOKEN_DATA SIZE_OF_PADDED_CONNECT_TOKEN

write(io, connect_token)

Expand Down

0 comments on commit cafba60

Please sign in to comment.