Hi Rich,
Maybe lsof helps:
ruby -e '
require "webrick"
h = WEBrick::HTTPServer.new(:Port => 8765)
h.mount_proc("/"){|q,s|
s.body = `sudo lsof -i -P`.grep(/:#{q.peeraddr[1]}->/).join("\n")
}
trap("INT"){h.shutdown}
h.start
'
As Dan said, that is not socket nature however.
Gotoken
On 2005/09/28 23:43 Dan Janowski wrote:
> I do not believe what you are looking for is available. I faintly
> recall that user information is available in SYSV streams, but not over
> TCP/IP sockets.
>
> In any event, something like this coming over the network cannot be
> trusted as it can be forged. That is why authentication exists.
>
> Dan
>
> On Sep 28, 2005, at 10:10, Rich Morin wrote:
>
>> I'd like to tweak WEBrick so that it will only respond to the user
>> that started it (i.e., the user whose uid matches WEBrick's). We
>> can assume, for simplicity's sake, that the user is running a web
>> browser on the same (Unixish) machine as WEBrick.
>>
>> I _suspect_ that WEBrick can get the needed information by looking
>> at the incoming socket (e.g., for a pid), than researching which
>> uid that pid has. Unfortunately, I know little about the innards
>> of sockets and even less about the innards of WEBrick.
>>
>> Comments, clues, and suggestions are all welcome.
>>
>> -r
>> --
>> email: rdm@cfcl.com; phone: +1 650-873-7841
>> http://www.cfcl.com - Canta Forda Computer Laboratory
>> http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc.
>>
>>
>
>