This repository was archived by the owner on Mar 16, 2021. It is now read-only.
-
Couldn't load subscription status.
- Fork 1
Communication between Client and Name Server
Ilya Makarenko edited this page Oct 7, 2020
·
10 revisions
All communication will be made using the following schema:

- Logout. Remove the given token from the Name Server's database. Response for this request is status.
- Register. For given login and password creates a record in the Name Server's database. Also creates a token for a session and initializes client storage for a given user. Response for this request is token.
- Login. Get an authorization token if given login and password are valid. Response for this request is a token.
- Initialize. Initialize the client storage in the system, removing any existing files root directory. Response for this request is status.
- File create. Creates a new empty file. Response for this request is status.
- File read. Reads a file from the system, providing a link for downloading. Response for this request is server.
- File write. Puts a file to the system, providing a link for uploading. Response for this request is server.
- File delete. Deletes a file from the system. Response for this request is status.
- File info. Provides information about the file in UTF-8 string. Response for this request is status.
- File copy. Creates a copy of the file with the given name. Response for this request is status.
- File move. Moves a file to the specified path. Response for this request is status.
- Read directory. Return a list of files in the directory as UTF-8 string. Response for this request is status.
- Make directory. Create a new directory in the system. Response for this request is status.
- Delete directory. Delete directory and all including files and folders in the system. Response for this request is status.
- Logout.

- Register.

- Login.

- Initialize.

- File create.

- File read.

- File write.

- File delete.

- File info.

- File copy.

- File move.

- Read directory.

- Make directory.

- Delete directory.

- Token. Returns a 32-byte long token which will be used for authorization.
- Server. Returns information about the server, where we can upload/download the file.
- Status. Returns a custom message.
- Token.

- Server.

- Status.

Example:
total 4
f file.txt
f file2.txt
f file2copy.txt
d folder
First string contains the word “total” followed by the “ ” (space) character followed by an amount of entities in the directory.
All following lines are following format: (“f”|”d”)<space><STRING>
Where:
- (“f”|”d”) determines type of entity, file or directory
- <space> is “ ” (space, ascii code is 0x20) symbol
- <STRING> is name of the entity
Line endings must be windows-styled (\r\n)
2 4060 2020-10-06 17:29:55 file.txt
Where
- 2 - Amount of replicas of this file
- 4060 - Size of file
- 2020-10-06 - Creation date
- 17:29:55 - Creation time
- file.txt - File name
Status response supports custom error codes, instead of just 00. Here you can see the full list of error codes:
Code Description
0x00 OK
0x1_ Authorization error
0x10 Unknown authorization error
0x11 Username already registered
0x12 Invalid username during registration
0x13 User does not exists
0x14 Incorrect password
0x15 Invalid token
0x2_ File error
0x20 Unknown file error
0x21 File does not exist
0x22 File already exists
0x23 Not enough space to create this file
0x24 Prohibited filename
0x3_ Directory error
0x30 Unknown directory error
0x31 Directory does not exist
0x32 Directory already exists
0x33 Prohibited directory name
0x8_ Other errors
0x80 Unknown server error
0x81 Wrong request id
Lost? Return to the home page