Recent

Author Topic: fcl-web : Request IP  (Read 17659 times)

Mukatai

  • New Member
  • *
  • Posts: 28
fcl-web : Request IP
« on: November 07, 2013, 05:21:39 pm »
Hello,

I create an application based on simplehttpserver exemple of fcl-web. (lazarus\fpc\2.6.2\source\packages\fcl-web\examples\httpserver)

In TTestHTTPServer.HandleRequest procedure, I am trying to get the ip address of request. I can get the useragent & cookies but i can't get the ip.

How can I get the IP of the request ?

Another query on this exemple, on linux (with a raspberry) when i compil & execut the code i have this error : Binding of socket failed: 80

To not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging)

Thanks,
Bye.
« Last Edit: November 07, 2013, 05:24:49 pm by Mukatai »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web : Request IP
« Reply #1 on: November 07, 2013, 05:45:31 pm »
Quote
How can I get the IP of the request ?
Check request headers, it should be one of them.
Quote
To not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging)
Try another port, it might be used already. Anyway, Linux tend to release used port a little later after it's closed. In my desktop, I usually need to wait about 10 seconds before trying to bind the same port.

Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #2 on: November 08, 2013, 10:15:23 am »
Hello,

Thanks for your reply.

Quote
How can I get the IP of the request ?
Check request headers, it should be one of them.
X-Forwarded-For could be correspond but it's not avialable in fcl-web component. And it's not really what I want. I think it is in ARequest.Connection.Socket but i don't find  >:(

Quote
To not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging)
Try another port, it might be used already. Anyway, Linux tend to release used port a little later after it's closed. In my desktop, I usually need to wait about 10 seconds before trying to bind the same port.

I can try all port it will not work. The only solution is launch application with sudo right and i want lazarus launch my application with sudo rights. It's possible ?

Bye.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web : Request IP
« Reply #3 on: November 08, 2013, 06:06:33 pm »
Quote
X-Forwarded-For could be correspond but it's not avialable in fcl-web component
Try ARequest.RemoteAddr.
Quote
i want lazarus launch my application with sudo rights. It's possible ?
Run->Run Parameters->Use Launching Application, use $(TargetCmdLine) IDE macro to point to your executable.

Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #4 on: November 13, 2013, 04:35:47 pm »
Hello,

Run->Run Parameters->Use Launching Application, use $(TargetCmdLine) IDE macro to point to your executable.
Don't work for me. But the simplehttpserver exemple of fcl-web work perfect and my console application have the error message (Binding of socket failed). So I need to find the difference ...

Try ARequest.RemoteAddr
The result is still empty (test in local and remote, on more browser). I tried also:
- ARequest.RemoteAddresse
- ARequest.RemoteHost
- ARequest.Host
- ARequest.From
- ARequest.Location
and other but the result is the same : empty  >:(
Another idea?

Thanks,
Bye.

parcel

  • Full Member
  • ***
  • Posts: 143
Re: fcl-web : Request IP
« Reply #5 on: November 14, 2013, 05:55:37 am »
how about "ARequest.Connection.Socket.RemoteAddress"?

My failed project src may help  :-[


Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web : Request IP
« Reply #6 on: November 14, 2013, 09:53:46 am »
Quote
The result is still empty (test in local and remote, on more browser). I tried also:
- ARequest.RemoteAddresse
- ARequest.RemoteHost
- ARequest.Host
- ARequest.From
- ARequest.Location
and other but the result is the same : empty  >:(
Another idea?
Probably a 2.6.2 bug, I used 2.7.1 and it works here.

Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #7 on: November 14, 2013, 12:02:35 pm »
Hi,

Ok I'll test on FPC 2.7.1 and it's RemoteAddr where you see the ip request ?

Thanks for your help Leledumbo.
@+

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web : Request IP
« Reply #8 on: November 14, 2013, 02:37:59 pm »
Quote
Ok I'll test on FPC 2.7.1 and it's RemoteAddr where you see the ip request ?
Try the attached project.

Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #9 on: November 14, 2013, 03:03:00 pm »
After test with FPC 2.7.1 RemoteAddr & RemoteAddress return IP of request. I tested your project and all property are empty except RemoteAddr (With FPC 2.7.1 but all are empty with FPC 2.6.2). Now I must find a way to update my rapsberry with FPC 2.7.1...

@+
« Last Edit: November 14, 2013, 03:17:36 pm by Mukatai »

Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #10 on: November 14, 2013, 03:16:26 pm »
how about "ARequest.Connection.Socket.RemoteAddress"?

My failed project src may help  :-[

ARequest.Connection.Socket.RemoteAddress need convert a sockaddr to string. But i think ARequest.Connection.Socket.RemoteAddress = ARequest.RemoteAddress with convert...

@+

almp1

  • New Member
  • *
  • Posts: 13
Re: fcl-web : Request IP
« Reply #11 on: December 21, 2016, 02:53:56 pm »
If you use load balance try again for apache2+centos6

yum -y install httpd-devel
mkdir /usr/local/src/mod_remoteip
cd /usr/local/src/mod_remoteip/
wget https://raw.githubusercontent.com/ttkzw/mod_remoteip-httpd22/master/mod_remoteip.c
wget https://raw.githubusercontent.com/ttkzw/mod_remoteip-httpd22/master/mod_remoteip.conf
wget https://raw.githubusercontent.com/ttkzw/mod_remoteip-httpd22/master/Makefile
yum -y install gcc
apxs -i -c -n mod_remoteip.so mod_remoteip.c


crete file in /etc/httpd/conf.d/mod_remoteip.conf
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPProxiesHeader X-Forwarded-By

service httpd restart

 :D


Mukatai

  • New Member
  • *
  • Posts: 28
Re: fcl-web : Request IP
« Reply #12 on: January 18, 2017, 11:10:28 pm »
Hi,

Finally i created my own http server based on socket with synapse. (3 years ago)

And fcl-web don't use httpd. (to my knowledge)

@+

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: fcl-web : Request IP
« Reply #13 on: January 30, 2017, 12:48:12 pm »
And fcl-web don't use httpd. (to my knowledge)

Of course it does...
There are also the native httpdxx packages, btw.
« Last Edit: January 30, 2017, 12:50:52 pm by Thaddy »
Specialize a type, not a var.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web : Request IP
« Reply #14 on: January 31, 2017, 08:53:35 am »
And fcl-web don't use httpd. (to my knowledge)

Of course it does...
There are also the native httpdxx packages, btw.
No, it doesn't (for serving). httpdXY packages are provided to create apache modules, which is only one out of several ways to create a web application. The embedded HTTP server and F(CGI) doesn't use them at all.

 

TinyPortal © 2005-2018