All the clients which are connected to the server will be automatically joined to the room 'code'. The message send will be send to all the users connected except the sender. When user execute a command, it will create a new json object containing socket id and encrypted command and send to the other client. The Json Object is created to store the socket id so that the result is send to only that user that executed the command. All the server Logs will be found in server.log and client log at client.log .
The message and commands will be encrypted by Client Public Key at client side and send to the server. At server, It is decrypted using Client Private Key and encrypted again using Server Private Key and send to the required client. At the destination client, it is decrypted again using Server Private Key and evaluated as necessary.
Technology Used: NodeJS
Additional Libraries: Express, crypto, node-rsa, socket.io, socket.io-client, chalk, js-priority-queue, repl
Libraries Use:
Express: It is used for starting the Server.
crypto and node-rsa : They are used for encrypting and decrypting message.
socket.io: It is used for creating socket at server side.
socket.io-client: It is used for creating socket at client side.
chalk: It is used to add color to terminal text.
js-priority-queue: It is used to define priority messaging queue.
repl: It is used to provice interactive shell that processes Node. js expressions
generate_keys.js : This file contain code to creation of Private and Public client and server keys.
encrypt_decrypt.js : This file contain code to encrypt a message and decrypt it back.
server.js : This file contain the server code.
client.js : This file contain the code for client side.
keys/ : This directory contain keys generated by file generate_keys.js .
client.log : Client logs.
server.log : Server logs.
The Server is Running on Localhost at PORT 3000
Step 1: RUN npm install
Step 2: RUN rm -dr keys
Step 3: RUN mkdir keys
Step 4: RUN node generate_keys.js
Step 5: RUN node check_keys.js //To Check if keys creation is correct or not. If error do all the steps again.
Step 6: RUN node server.js //To Start Server
Step 7: RUN node client.js //To Start Client
NOTE:
- The generation of keys may take a little more time then expected because of large key size.
- Modify Key size in generate_keys.js file if need to encrypt large data. Example: for ls command if directory contain 10 directories then it can be encrypted with key size 6144 but for ls -l command it will not fit in the key size 6144. So to encrypt ls -l output key size need to be increase and new keys need to be generated.
- Large Keys take more time in creation as compare to smaller key sizes. But encryption decryption will not take that much time.
Step 1: RUN npm install
Step 2: RUN node check_keys.js //To check if encryption and decryption in working fine if not go with above give Instruction to //Run with new Private and Public Keys for client and server
Step 3: RUN node server.js //To Start Server
Step 4: RUN node client.js //To Start Client
After Running the Server. Start another terminal 2 or 3 and run client (node client.js) in that you can send message which will be transmitted to all the other connected terminals. For command, its result and error will appear only on that terminal which executed the command.
Usage: msg: cmd:
if not operation is specified or wrong operation is given, client will show usage.
For Further Info About the Steps in Files See Comments in each file giving Information about almost all steps.