Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. ##Nodejs Peer to Peer over TCP
  2. -----------------------------------
  3. ### Bootup
  4. - Check if an .userrc file is present, if not
  5. - calculate the hash of the user's ipv4 and create an user name, notify the user to reset it with `node start.js -u username`
  6. - Scan all the available ip's listening on the `PORT`
  7. - Start a tcp server on `PORT`
  8.  
  9. ### Scanning
  10. - Create a socket and ping all ips starting from `192.168.x.y`, where x is either hard-coded or retrived from users ipv4 address, on `PORT`
  11. - A server recieves, a `{type: "ping"}`, and responds back with a `{type: "pong", nick: user_name}`, this pong object, combined with ip is stored in an inmemory database
  12.  
  13. ### Connecting
  14. - The user is provided with a prompt to type in commands
  15. - To connect an user types in `/connect <ip>/<nick>`, in case of nick, the ip is retrived from database
  16. - The initiator creates a connection socket with the provided `ip` and default `PORT`
  17. - The client server, on recieving a connection, gets the `remoteAddress` , and creates a connection with the ip as `remoteAddress`
  18. - Rest of the communication is like a normal chat
  19. - `/leave <nick>` stops the client connection
  20.  
  21. ### Implementation Pain Points
  22.  
  23. - Given the same code running on initiator and reciever, how to the achieve points 2 and 3 at the same time.
  24. - A socket is full duplex (HTW do I utilize that information), Is the above point necessary, if not what is the correct way
  25. - Multiple users connecting to an user, Need to maintain a list of `client sockets` and maybe instead of `/connect <ip>`, use `/tell <ip>/<nick> message` and destroy the connection after one message
  26. - PGP encryption FTW
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement