And with IP addresses I mean both the LAN and Internet interfaces available on his system.
Technically the P2P API works in the following way:
- user A uses SendP2PPacket to user B
- a callback on user B tells him that user A wants to send packets
- user B can ignore it, or use AcceptP2PPacketsFromUser or another SendP2PPacket to accept it
- at this point the NAT traversal mechanism allows the users to send and receive packets
What's interesting instead is that some games have the third point (accepting the packets) as an automatic operation even if you are not hosting a lobby/server and you are just a normal player.
One of these games is DOTA 2 (appID 570), in fact it's enough to load the game and after the loading screen the game is able to receive the packets and the IP address can be retrieved easily.
The target can be any user, not only your friends.
I have just released a tool to test this simple mechanism, steamuserip:
http://aluigi.org/papers.htm#steamuserip
Using it is very simple:
Code: Select all
steamuserip 570 7656119**********
The ID is available in the URL of the Steam profile of the user or, if it's a custom URL, it's enough to add /?xml=1:
Code: Select all
http://steamcommunity.com/profiles/7656119**********
http://steamcommunity.com/id/TARGET_NICKNAME/?xml=1
Code: Select all
<profile>
<steamID64>7656119**********</steamID64>
<steamID>*******</steamID>
<onlineState>online</onlineState>
The tool is also able to scan the whole online lobbies if you specify the steamID 0 (or ""), with some games you may be able to retrieve also the IP address of the other users in the lobby, not just the hoster/owner of the lobby.
Additional information are available at runtime, I copy&paste them here as reference:
Code: Select all
steamuserip 0.1
by Luigi Auriemma
e-mail: me@aluigi.org
web: aluigi.org
Usage: steamuserip <appID> <steamID/64/"">
If the steamID is 0 or "", the tool will get the online lobbies, join them
and scan all the users currently in them (in some games it may work).
The user must be online and playing with the same game of appID.
If you get only a LAN IP address, retry again.
You may get also the Steam relay servers like 146.66.15*.*
Other Steam servers may be 208.78.16*.*
If you get only LAN and relay IP address, retry again.
Remember that the results are game depend, this is not an universal solution.
This tool is only a proof-of-concept, it may be updated in future.
Please note that may exist other better ways to retrieve the IP addresses of non-friend Steam users, this is just a proof-of-concept based on the Steamworks API.