implemented RegisterRequest handler
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "tlibc/errors.h"
|
||||
#include "magic.h"
|
||||
#include "common_constants.h"
|
||||
|
||||
#define AES_SESSION_KEY_SIZE 32
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ Result(void) RegisterRequest_tryConstruct(RegisterRequest *ptr, PacketHeader* he
|
||||
_PacketHeader_construct(RegisterRequest);
|
||||
|
||||
try_assert(username.size >= USERNAME_SIZE_MIN && username.size <= USERNAME_SIZE_MAX);
|
||||
ptr->username_size = username.size;
|
||||
memcpy(ptr->username, username.data, username.size);
|
||||
ptr->username[username.size] = 0;
|
||||
|
||||
try_assert(token.size == sizeof(ptr->token));
|
||||
memcpy(ptr->token, token.data, token.size);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "tlibc/errors.h"
|
||||
#include "tlibc/string/str.h"
|
||||
#include "network/tcp-chat-protocol/constant.h"
|
||||
#include "cryptography/cryptography.h"
|
||||
|
||||
#define PROTOCOL_VERSION 1 /* 1.0.0 */
|
||||
#define NETWORK_BUFFER_SIZE 65536
|
||||
@@ -80,14 +79,8 @@ void LoginResponse_construct(LoginResponse* ptr, PacketHeader* header,
|
||||
u64 user_id, u64 landing_channel_id);
|
||||
|
||||
|
||||
#define USERNAME_SIZE_MIN 4
|
||||
#define USERNAME_SIZE_MAX 64
|
||||
#define PASSWORD_SIZE_MIN 8
|
||||
#define PASSWORD_SIZE_MAX 32
|
||||
|
||||
typedef struct RegisterRequest {
|
||||
u32 username_size;
|
||||
char username[USERNAME_SIZE_MAX];
|
||||
char username[USERNAME_SIZE_MAX + 1]; // null-terminated
|
||||
u8 token[PASSWORD_HASH_SIZE];
|
||||
} ALIGN_PACKET_STRUCT RegisterRequest;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user