Local network P2P file transfer

One of my University assignments is to develop a P2P file sharing web application to transfer files between machines on the same local network. I'm not looking for a handout on how to do this, I can figure it out once I get the high level design down, I just need to know if this is sane.

I'm planning on using the PeerJS library. From what I can tell each client gets a unique ID and these IDs are used to connect clients to each other. So somehow I need to coordinate IDs between all the clients on the same local network.

The way I was planning on doing this is to have a NodeJS server running with Socket.IO. When the client loads the web application, they send a websocket request to the Node server. The node server then records the external IP address of the client. When another client connects and makes a request with the same external IP address as another client, those two clients are given each other's IDs so they can connect to each other.

There are a few potential problems with this:

  • I'm assuming people with the same external IP address are on the same local network. Would this be wrong in any situations?
  • I don't know how the file transfer between clients will happen. Ideally it should be isolated to the local network. For example if I'm transferring a file between two computers it will go: computer 1 -> router/switch -> computer 2, not something like computer 1 -> router/switch -> local exchange -> ISP switch -> local exchange -> router/switch -> computer 2. Basically the transfer shouldn't leave the local network onto the Internet.

Thoughts?