function getClientRealIpAddress(socket) {
    const headers = socket.request.headers

    // Standard headers used by Amazon EC2, Heroku, and others.
    if (headers['x-client-ip']) return headers['x-client-ip']

    // Load-balancers (AWS ELB) or proxies.
    const xForwardedFor = getClientIpFromXForwardedFor(headers['x-forwarded-for'])
    if (xForwardedFor) return xForwardedFor

    // Cloudflare. @see https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-
    // CF-Connecting-IP - applied to every request to the origin.
    if (headers['cf-connecting-ip']) return headers['cf-connecting-ip']

    // DigitalOcean. @see https://www.digitalocean.com/community/questions/app-platform-client-ip
    // DO-Connecting-IP - applied to app platform servers behind a proxy.
    if (headers['do-connecting-ip']) return headers['do-connecting-ip']

    // Fastly and Firebase hosting header (When forwared to cloud function)
    if (headers['fastly-client-ip']) return headers['fastly-client-ip']

    // Akamai and Cloudflare: True-Client-IP.
    if (headers['true-client-ip']) return headers['true-client-ip']

    // Default nginx proxy/fcgi alternative to x-forwarded-for, used by some proxies.
    if (headers['x-real-ip']) return headers['x-real-ip']

    // (Rackspace LB and Riverbed's Stingray)
    // http://www.rackspace.com/knowledge_center/article/controlling-access-to-linux-cloud-sites-based-on-the-client-ip-address
    // https://splash.riverbed.com/docs/DOC-1926
    if (headers['x-cluster-client-ip']) return headers['x-cluster-client-ip']

    if (headers['x-forwarded']) return headers['x-forwarded']

    if (headers['forwarded-for']) return headers['forwarded-for']

    if (headers.forwarded) return headers.forwarded

    // Google Cloud App Engine
    // https://cloud.google.com/appengine/docs/standard/go/reference/request-response-headers

    if (headers['x-appengine-user-ip']) return headers['x-appengine-user-ip']

    // else get ip from socket.request that returns the reference to the request that originated the underlying engine.io Client
    if ( socket.request?.connection?.remoteAddress ) return socket.request.connection.remoteAddress

    // else get ip from socket.handshake that is a object that contains handshake details
    return socket.handshake.address
}
Get client real ip address
Borrowed from https://github.com/pbojinov/request-ip/blob/master/src/index.js
@param {socketio.Socket} socket Socket.IO socket object
@returns {string | string[] | undefined} Best estimate of the client's real IP address