Xonotic Forums
[SUGGESTION] Possibility to get own ip:port through RCON? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10)
+--- Forum: Xonotic - Suggestion Box (https://forums.xonotic.org/forumdisplay.php?fid=20)
+--- Thread: [SUGGESTION] Possibility to get own ip:port through RCON? (/showthread.php?tid=1259)

Possibility to get own ip:port through RCON? - Akari - 11-26-2010

I am working on an interactive RCON client for Nexuiz/Xonotic. I need the user to see everything what's going on at the server, read chat, etc. Much like rcon2irc, I use the log_dest_udp feature to achieve that, however, I ran into a problem, which also exists in rcon2irc since I used the same method. The method works fine if I connect to a server inside of my home network, however, it fails on a remote server because getsockname() (Python) returns the local address of my machine (eg., which is obviously not useable). I have worked it around by querying this service for my external IP address; assuming port is the same it seems to work for me. But in my opinion, this is an ugly workaround because:
  • It slows down the connection in a noticeable way
  • It still won't handle a connection to localhost
  • Relying on a side service is the last thing I want to do

What I am suggesting is a special RCON-only command, say, whoami. When the server recieves a whoami command, it just sends a pair of client's ip:port that is useable for log_dest_udp back to the client. This way, my RCON client will send a "whoami" command on connection, parse and store the reply and start querying log_dest_udp from time to time, adding itself if missing. With this approach, a failure will be nearly impossible. Would that be hard to implement? Or are there any better solutions? Perhaps there is already one and I'm missing it?