sinProject-Inc/talk

View on GitHub
src/lib/network/socket_client_address.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { Socket } from 'socket.io'

export class SocketClientAddress {
    public constructor(private readonly _socket: Socket) {}

    public get value(): string {
        const client_address =
            (this._socket.handshake.headers['x-forwarded-for'] as string) ||
            this._socket.handshake.address

        return client_address
    }
}