How to know client ip address?

shadinata
2010-07-02
2013-04-25
  • shadinata

    shadinata - 2010-07-02

    how to know client ip address?
    since xmlrpc has no security, i think ip filter will be a simple solution…

     
  • DremLIN Ru

    DremLIN Ru - 2010-09-29

    Hi,

    If you use XmlRpcServer with Indy10: (See: demos > delphi > server > threaded > Main.pas)

    121 procedure TForm1.HelloMethod(Thread: TRpcThread; const MethodName: string;
    122     List: TList; Return: TRpcReturn);
    123 var
    124   Msg: string;
    125 begin
    126   {The parameter list is sent to your method as a TList of parameters
    127   this must be casted to a parameter to be accessed. If a error occurs
    128   during the execution of your method the server will fall back to a global
    129   handler and try to recover in which case the stack error will be sent to
    130   the client}
    131 
    132   {grab the sent string}
    133   Msg := TRpcParameter(List[0]).AsString;
    134 
    135   {return a message showing what was sent}
    136   Return.AddItem('You just sent ' + Msg);
    137 
    138   // synchronize the method handler with the VCL main thread
    139   FCriticalSection.Enter;
    140   try
    141     FMessage := IntToStr(GetCurrentThreadId) + ' ' + Msg;
    142     {$ifdef INDY9}
    143     Thread.Synchronize(AddMessage);
    144     {$endif}
    145     {$ifdef INDY10}
    // DremLIN BEG
        PID := GetCurrentThreadId; // Process ID
        IP := Thread.Connection.Socket.Binding.IP; // Server IP
        PeerIP := Thread.Connection.Socket.Binding.PeerIP; // Client IP
    // DremLIN END
    146     Tidsync.SynchronizeMethod(AddMessage);
    147     {$endif}
    148   finally
    149     FCriticalSection.Leave;
    150   end;
    151 end;
    

    If you use XmlRpcServer with Indy9 - I don't now  :((

    Regards.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks