JDDEV Posted June 15, 2018 Posted June 15, 2018 Hi, Actualy, i use the property "UniApplication.RemoteAddress" to get the remote IP of the user. I would like to get this information before, when an exception broke the connexion "InvalidSession" or "TermnateSession" on the ServerModule. The goal is to "auto connect" the user if his IP is in my list of "Admin IP". Is it possible ? Thanks Quote
Fred Montier Posted July 21, 2018 Posted July 21, 2018 (edited) Simple: unisession.RemoteIPIt's embeded in the session. Otherwise, the server would not "howto knows" where to send the data. Edited July 21, 2018 by fredmontier Quote
ygerdel Posted November 28, 2019 Posted November 28, 2019 Hi, I am currently using UniSession.RemoteIP to obtain the ip of the sessions of the users that enter my application, however there is a firewall in the middle and UniSession.RemoteIP is registering the ip of the firewall and not of the sessions of each user. Is there any way to get it ip from each user's session? Quote
Sherzod Posted November 28, 2019 Posted November 28, 2019 http://forums.unigui.com/index.php?/topic/8946-passing-clients-apparent-public-ip-to-unigui-session-on-login-button-click/&do=findComment&comment=72178 Quote
mazluta Posted July 22, 2024 Posted July 22, 2024 i use this approach : unit ServerModule; ....... interface ....... type TServerExternalData = record ExternalIP : String; {77.137.79.118} City : String; {Tel Aviv} Region : String; {Tel Aviv} Country : String; {IL} Location : String; {32.0809,34.7806} InternetCompany : String; {AS12849 Hot-Net internet services Ltd} TimeZone : String; {Asia\/Jerusalem} end; on the PUBLIC section ..... public { Public declarations } function GetExternalData() : TServerExternalData; end; ..... implementation {$R *.DFM} ....... function TUniServerModule.GetExternalData() : TServerExternalData; var LJsonObj : TJSONObject; Http : TIdHttp; RsltStr : String; begin Result.ExternalIP := ''; Result.City := ''; Result.Region := ''; Result.Country := ''; Result.Location := ''; Result.InternetCompany := ''; Result.TimeZone := ''; Try Http := TIdHTTP.Create(nil); try RsltStr := Http.Get('http://ipinfo.io/json'); LJsonObj := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(RsltStr),0) as TJSONObject; // "ip":"77.137.79.118" // "city":"Tel Aviv", // "region":"Tel Aviv", // "country":"IL", // "loc":"32.0809,34.7806", // "org":"AS12849 Hot-Net internet services Ltd." // "timezone":"Asia\/Jerusalem" Result.ExternalIP := LJsonObj.Get('ip').JsonValue.Value; Result.City := LJsonObj.Get('city').JsonValue.Value; Result.Region := LJsonObj.Get('region').JsonValue.Value; Result.Country := LJsonObj.Get('country').JsonValue.Value; Result.Location := LJsonObj.Get('loc').JsonValue.Value; Result.InternetCompany := LJsonObj.Get('org').JsonValue.Value; Result.TimeZone := LJsonObj.Get('timezone').JsonValue.Value; Except; end; Finally FreeAndNil(LJsonObj); FreeAndNil(Http); End; 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.