I'm currently in the process of creating a Skype-like program, that uses a hybrid peer to peer system to communicate between users (i.e. server contains all users IPs, a client that wants to connect to a friend will tell the server, that will then send each client the other's IP so they could start hole punching to establish a connection between them).
I know that with Skype, there are many websites that allow you to enter a username and easily get his IP address. My question is, what is the best way of preventing such an exploit?
Here are a few solutions I could think of:
- save each and every users' friends lists on the server (so the server can just drop IP requests from users that aren't in the requested client's friends list)
- whenever the server is asked for a client's IP, ask that client if the asker is on their friends list (if not, don't reply)
- have each client use some secret key to communicate with the server (so only registered clients will be able to send IP requests)
Feel free to add a different solution, again, these are just solutions I could think of off the top of my head while writing this question.
In addition, a related question that I wanted to ask - what would be the best practice in such a program:
Have each client store his friends' IPs and make the server notify him whenever they are changed
-VS-
Have the client ask the server for a friend's IP whenever he wants to start a direct connection with him (keep in mind that the client anyway has to tell the server whenever he's trying to connect to someone, in order for the hole punching to work).
P.S. I've never created such a program and I'm not following any tutorial or such. If there's any better way of doing something I wrote, or if I got anything wrong, I'd be very glad if you could mention it.