pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Obtaining client IP address
3+ messages / 2 participants
[nested] [flat]

* Obtaining client IP address
@ 2006-02-24 23:16 Alexis Paul Bertolini <bertolini@computer.org>
  2006-02-24 23:34 ` Re: Obtaining client IP address Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Alexis Paul Bertolini @ 2006-02-24 23:16 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I need to have a db table containing all connected clients (of a 
distributed application) and among other info, their IP.

If both the client and the server are on the same LAN, no problem, the 
client can supply it's own info. But if they are connected via some sort 
of bridge/router/NAT? For instance, a client on a LAN connects to a 
server over the Internet?

The client has no idea what public IP it has. The server ought to 
know... however I haven't found how I could get this info into my query.

What I need is some sort of procedure whereby the client enrolls onto 
the system and supplies the info...

I hope I made my self clear. If not I can try and be more specific!

Alex.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Obtaining client IP address
  2006-02-24 23:16 Obtaining client IP address Alexis Paul Bertolini <bertolini@computer.org>
@ 2006-02-24 23:34 ` Michael Fuhr <mike@fuhr.org>
  2006-02-25 09:26   ` Re: Obtaining client IP address Alexis Paul Bertolini <bertolini@computer.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Fuhr @ 2006-02-24 23:34 UTC (permalink / raw)
  To: Alexis Paul Bertolini <bertolini@computer.org>; +Cc: pgsql-sql

On Sat, Feb 25, 2006 at 12:16:31AM +0100, Alexis Paul Bertolini wrote:
> The client has no idea what public IP it has. The server ought to 
> know... however I haven't found how I could get this info into my query.

What version of PostgreSQL are you running?  In 8.0 and later you
can use inet_client_addr().

http://www.postgresql.org/docs/8.1/interactive/functions-info.html

I forget if earlier versions have a way to get the client's IP
address without resorting to hacks (e.g., writing a function in a
privileged language like plperlu and calling netstat or lsof).

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Obtaining client IP address
  2006-02-24 23:16 Obtaining client IP address Alexis Paul Bertolini <bertolini@computer.org>
  2006-02-24 23:34 ` Re: Obtaining client IP address Michael Fuhr <mike@fuhr.org>
@ 2006-02-25 09:26   ` Alexis Paul Bertolini <bertolini@computer.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Alexis Paul Bertolini @ 2006-02-25 09:26 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

Michael Fuhr wrote:
> On Sat, Feb 25, 2006 at 12:16:31AM +0100, Alexis Paul Bertolini wrote:
>   
>> The client has no idea what public IP it has. The server ought to 
>> know... however I haven't found how I could get this info into my query.
>>     
>
> What version of PostgreSQL are you running?  In 8.0 and later you
> can use inet_client_addr().
>
> http://www.postgresql.org/docs/8.1/interactive/functions-info.html
>
> I forget if earlier versions have a way to get the client's IP
> address without resorting to hacks (e.g., writing a function in a
> privileged language like plperlu and calling netstat or lsof).
>
>   
Mmmm, I didn't spot that one, but it did the trick! Thanks!

Alex.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-02-25 09:26 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-24 23:16 Obtaining client IP address Alexis Paul Bertolini <bertolini@computer.org>
2006-02-24 23:34 ` Michael Fuhr <mike@fuhr.org>
2006-02-25 09:26   ` Alexis Paul Bertolini <bertolini@computer.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox