Receiving information about client on server-side

procedure TNewService.RORemoteDataModuleGetDispatchInfo(
const aTransport: IROTransport; const aMessage: IROMessage);
var
  tcpinfo:IROTCPtransport;
  httpinfo:IROHTTPTransport;
  client_address: string;
begin
   client_address := '';
    if Supports(aTransport, IROTCPtransport, tcpinfo) then
      client_address := tcpinfo.GetClientAddress;
    if client_address = '' then
      if Supports(aTransport, IROHTTPTransport, httpinfo) then begin
        client_address := httpinfo.Headers['REMOTE_ADDR'];
        if client_address = '' then client_address := httpinfo.Headers['HTTP_CLIENT_IP'];
        if client_address = '' then .... // check for others headers like REMOTE_ADDR, 
					 //HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR (can be comma delimited list of IPs), 
					 //HTTP_X_FORWARDED, HTTP_X_CLUSTER_CLIENT_IP, 
					 //HTTP_FORWARDED_FOR, HTTP_FORWARDED
      end;
  //Log('Client ' + client_address + ' connected!');
end;
3 Likes