Get client IP with fcl-web lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Trenatos · 2018-09-29 01:03 I'm replacing an Elixir based website with one built in FPC using fcl- web/fphttpserver. It's working fine, but I can't figure out how to get the clients IP address from the request. I'm implementing Google captcha, which needs to include the users IP address for server<->google communication. I can't post the whole thing as it includes API keys, but I'm using an TFPHTTPConnectionRequest I've found that I can access ARequest.Connection.Socket.RemoteAddress but I don't know how to get from here to an IPv4 string, anyone done this? ---------------------------------------------------------------------- Trenatos · 2018-09-29 02:06 Because I use CloudFlare, I got the IP through the forwarded-for header. In case someone else could use that info: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ARequest.GetCustomHeader('X-Forwarded-For') ---------------------------------------------------------------------- lucamar · 2018-09-29 13:24 I haven't got time ATM to look into the fcl-web sources but ... An IPv4 address is just a 32 bits unsigned integer (network endiannes), which means in code they ususally are either a DWord or a packed array of four bytes. Thus it should be easy to convert them to strings. For example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TIPConvert = packed record  case Boolean of  True: (AsDWord: DWORD)  False: (AsBytes: packed array [0..3] of byte);  end; function IPString(const IP: array of byte): String; overload;begin  Result := Format('%u"."%u"."%u"."%u',[IP[0],IP[1],IP[2],IP[3]]);end; function IPString(const IP: DWord): String; overload;var  AnIPRec: TIPConvert;begin  AnIPRec.AsDWord := IP;  Result := IPString(AnIPRec.AsBytes)end; ---------------------------------------------------------------------- heejit · 2018-09-29 14:08 Try: ARequest.RemoteAddress