RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/lib/getClientAddress.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { ISocketConnection } from '@rocket.chat/core-typings';

export function getClientAddress(connection: Pick<ISocketConnection, 'clientAddress' | 'httpHeaders'>): string {
    if (!connection) {
        return '';
    }

    const { clientAddress, httpHeaders } = connection;

    return clientAddress || (httpHeaders?.['x-real-ip'] as string);
}