This topic describes how to obtain real IP addresses of clients that access a game running on a Linux server.

Integrate a TOA module by using application hooks

  1. Run the install.sh script to install services that relate to the toa_server.
  2. Specify preload.so when starting an application service. If the name of an application service is nginx, you can use the following command to start the application server.
    LD_PRELOAD=./preload.so ./nginx
    Note You must find the entry point of your program and include the parameter in the preceding command to start the service.
    nginx service
    1. Run the install.sh script.
    2. Check whether the /usr/lib/systemd/system/nginx.service file exists.
    3. Use the following command to update the mynginx.sh script.
      cat > /root/mynginx.sh
    4. Add the following statements to the mynginx.sh file and replace path-to-preload.so with the full path of the preload.so file.
      #! /bin/bash
      LD_PRELOAD=path-to-preload.so /usr/sbin/nginx
    5. Use the following command to modify the permissions for the mynginx.sh file.
      chmod +x /root/mynginx.sh
    6. Use the following command to edit the nginx.service file.
      vi /usr/lib/systemd/system/nginx.service
    7. Replace ExecStart=/usr/sbin/nginx with ExecStart=/root/mynginx.sh.
    8. Use the following command to restart the nginx service.
      service nginx restart
    9. Use the following command to enable automatic start for the nginx service at startup.
      systemctl enable nginx.service
      Note You can also start the nginx service by adding the following statements to the nginx_reload.sh script.
      killall nginx
      LD_PRELOAD=path-to-preload.so /usr/local/nginx/sbin/nginx

      Then, you must add the directory where the nginx_reload.sh file resides to the rc.local startup configuration file.

  3. Check whether preload.so is loaded by the nginx service.
    The followin example command are provided for your reference.
    • To check whether a port is enabled: netstat -ntulp |grep 48888
    • To check whether the nginx service is running and view its PID: ps -ef | grep nginx
    • To check whether preload.so is loaded: cat /proc/PID/maps | grep preload.so

Integrate a TOA module by modifying application code

The TOA module of GameShield installs a process on an origin server. The process listens on UDP port 48888. A game process passes non-real port numbers and IP addresses to port 48888 by using a specific format and retrieves port numbers and real IP addresses from the process.

Precautions
  • You must make sure that UDP port 48888 is not disabled by the firewall on the localhost of 127.0.0.1.
  • When you configure settings to allow access to the endpoint of 127.0.0.1:48888 through UDP, you must specify a timeout period. This setting helps avoid denial of services due to unexpected issues.
  • You can retrieve real IP addresses by using the bypass method. In theory, retrieving real IP addresses seldom fails. However, you still need to prepare related solutions when an application process fails to retrieve real IP addresses.
  • In a server-client connection, data that relates to IP addresses and ports is deleted when one of the parties closes the connection socket. You must re-establish a connection between the server and the client to create data that relates to IP addresses and ports.

For more information, see the instructions that are provided in the TOA archive. You can also contact GameShield Technical Support.